问此身何故此生何处 发表于 2024-2-5 11:41:20

4.WPF样式使用规范

在Web开发的时候,编写css样式的时候通常是统一写在.css样式文件中。在WPF中也可以使用这样的思想。
样式引用:
1.新建一个项目用于统一存放样式WPF.UI
添加一个资源字典Button.xaml或者CheckBox.xaml等等....
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary> 
2.添加Generic.xaml用于统一管理所有文件
ResourceDictionary.MergedDictionaries是一个属性,它允许您将多个ResourceDictionary合并到一个ResourceDictionary中。这使得在应用程序中共享资源变得更加方便。
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary><ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary><ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary><ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary><ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary><ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary> 
3.在主项目中App.xaml添加引用
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary><ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary><ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary><ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary><ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary><ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary><ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary><ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary><ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary><ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary> 
4.使用
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary><ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary><ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary>     
图标引用:
1.创建一个文件夹用于存放图片,图片属性设置为资源

 2.添加一个资源文件Icon.xaml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary><ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary>BitmapImage 表示可以在WPF应用程序中使用的图像源。它用于在各种WPF控件中显示图像,如Image、ImageBrush和MediaElement。BitmapImage可以从各种来源创建,例如文件路径、流或URI。它提供了在WPF应用程序中加载、解码和操作图像的属性和方法。
3.在Generic.xaml文件里添加引用,如上。
4.添加一个转化器
///   /// 根据ICON的字符串名称转换为BitmapImage对象    ///   internal class IconToImageConverter : IValueConverter    {<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary>public object Convert(object value, Type targetType, object parameter, CultureInfo culture)<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary>{<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary>    return (BitmapImage)System.Windows.Application.Current.Resources[(string)value];<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary>}<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary>public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary>{<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary>    throw new NotImplementedException();<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary>}    }5使用
//.cs代码 public override string Icon => "Icon_Test";//.xaml代码<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary><ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary><ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary><ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary><ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary><ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary><ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary><ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="<strong>Icon_Test</strong>" UriSource="/WPF.UI;Component/Icon/010_出差申请.png"/>
    <BitmapImage x:Key="<strong>Icon_Sobel</strong>" UriSource="/WPF.UI;Component/Icon/010_打卡签到.png"/>
    <BitmapImage x:Key="<strong>Icon_MedianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_发现更多.png"/>
    <BitmapImage x:Key="<strong>Icon_GaussianBlur</strong>" UriSource="/WPF.UI;Component/Icon/010_费用报销.png"/>
</ResourceDictionary>    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

   
   

</ResourceDictionary>       

来源:https://www.cnblogs.com/MingQiu/p/18007533
免责声明:由于采集信息均来自互联网,如果侵犯了您的权益,请联系我们【E-Mail:cb@itdo.tech】 我们会及时删除侵权内容,谢谢合作!
页: [1]
查看完整版本: 4.WPF样式使用规范