zoukankan      html  css  js  c++  java
  • WPF通过DynamicResource的用法

    1.先在资源类库中编写:style.xaml,如下:

    <ResourceDictionary
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
     
      <!-- Background Style -->
      <Style x:Key="styleBackground">
        <Setter Property="Control.Background">
          <Setter.Value>
            <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5" Opacity="0.5">
              <GradientStop Color="LightSkyBlue" Offset="0" />
              <GradientStop Color="WhiteSmoke" Offset="0.5" />
              <GradientStop Color="LightSkyBlue" Offset="1" />
            </LinearGradientBrush>
          </Setter.Value>
        </Setter>
      </Style>
     
      <!-- Banner Style -->
      <Style x:Key="styleBanner">
        <Setter Property="StackPanel.Background">
          <Setter.Value>
            <LinearGradientBrush StartPoint="0,0.25" EndPoint="1,0.5">
              <GradientStop Color="#CC0088DD" Offset="0.3" />
              <GradientStop Color="#3300FFFF" Offset="0.85" />
            </LinearGradientBrush>
          </Setter.Value>
        </Setter>
        <Setter Property="TextBlock.Foreground" Value="Yellow" />
        <Setter Property="TextBlock.FontFamily" Value="Comic Sans MS" />
      </Style>
    </ResourceDictionary>
     
    2.在App.xaml类中,声明引用类型,
     <Application.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="pack://application:,,,/Resource;component/Styles/Style.xaml" />
                </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>
     </Application.Resources>
     
    3.在window、UserControl当中,直接使用动态资源,如下:
    <Window  x:Class="SkinnableApp.MainWindow"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   
      xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
     
      SizeToContent="Height"
      ResizeMode="NoResize"
      Width="680"
      WindowStartupLocation="CenterScreen"
      WindowStyle="ToolWindow">
      <Grid x:Name="Root" Style="{DynamicResource styleBackground}">
        <!-- BANNER -->
        <Grid Height="70" Style="{DynamicResource styleBanner}" >
          <TextBlock FontSize="26" Padding="10,0,10,0" Text="Insurance Agent Management System" VerticalAlignment="Center"/>
        </Grid>
    </Window>
  • 相关阅读:
    hibernate一级缓存和二级缓存的区别
    springmvc中的controller是单例的
    Java 冒泡排序
    spring mvc做上传图片,文件小于10k就不生成临时文件了
    java程序生成二维码
    MySQL调优
    根据从redis缓存的数据查询出来,在从数据库中取出所有的数据,俩个数据进行比较,去掉重复,剩下库中新插入的数据,取出新数据,然后把redis中的缓存数据清空把从数据库中查出来的所有数据放到redis缓存中
    找出list中的不同元素、删除两个list中相同的对象
    PowerDesigner如何将消失的工具栏显示出来
    Oracle基础(九) Oracle的体系结构
  • 原文地址:https://www.cnblogs.com/wlming/p/10070635.html
Copyright © 2011-2022 走看看