zoukankan      html  css  js  c++  java
  • 简单实现WPF界面控件换肤效果

    效果如下如图:选择皮肤颜色

    1.首先新建一个如图界面:

    选择匹夫下拉框Xaml代码如下:三种颜色选项,并触发SelectionChanged事件

    <ComboBox Height="23" Name="comboBox1" Width="120" SelectionChanged="comboBox1_SelectionChanged" IsEditable="False" HorizontalAlignment="Right">
                <ComboBoxItem Content="绿色"/>
                <ComboBoxItem Content="紫色"/>
                <ComboBoxItem Content="灰色"/>
    </ComboBox>

    2.新建三个资源字典文件分别为:

    三种皮肤。

    内部代码分别为:

    BlueSkin.xaml

     

    GraySkin.xaml

    PurpleSkin.xaml

    3.触发选择皮肤下拉框的SelectionChanged事件,实现换肤效果,代码如下:

    ComboBoxItem cmbItem = comboBox1.SelectedItem as ComboBoxItem;
    string item = cmbItem.Content.ToString();
     if (item == "绿色")
     {
                 rd.Source = new Uri(@"BlueSkin.xaml", UriKind.Relative);
                 Application.Current.Resources = rd;
      }
      if (item == "紫色")
      {
                rd.Source = new Uri(@"PurpleSkin.xaml", UriKind.Relative);
                Application.Current.Resources = rd;
      }
      if (item == "灰色")
      {
                rd.Source = new Uri(@"GraySkin.xaml", UriKind.Relative);
                Application.Current.Resources = rd;
      }

  • 相关阅读:
    第一次被队友说给力
    An Unfair Game-[ACdream1035]
    男人八题解题报告
    it's hard to say
    剪花布条[HDU2087]
    1117: 无序字母对 character
    20181101
    20181104
    20181102
    20181031
  • 原文地址:https://www.cnblogs.com/_ymw/p/3287874.html
Copyright © 2011-2022 走看看