一、颜色
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib"
>
<Color x:Key="LightPrimaryColor">#f3fbff</Color>
<Color x:Key="PrimaryColor">#326cf3</Color>
<Color x:Key="DarkPrimaryColor">#326cf3</Color>
<Color x:Key="LightDangerColor">#fff6f7</Color>
<Color x:Key="DangerColor">#db3340</Color>
<Color x:Key="DarkDangerColor">#db3340</Color>
<Color x:Key="LightWarningColor">#fffcf5</Color>
<Color x:Key="WarningColor">#e9af20</Color>
<Color x:Key="DarkWarningColor">#e9af20</Color>
<Color x:Key="LightInfoColor">#f1fdff</Color>
<Color x:Key="InfoColor">#00bcd4</Color>
<Color x:Key="DarkInfoColor">#00bcd4</Color>
<Color x:Key="LightSuccessColor">#f3fff6</Color>
<Color x:Key="SuccessColor">#2db84d</Color>
<Color x:Key="DarkSuccessColor">#2db84d</Color>
<Color x:Key="PrimaryTextColor">#212121</Color>
<Color x:Key="SecondaryTextColor">#757575</Color>
<Color x:Key="ThirdlyTextColor">#bdbdbd</Color>
<Color x:Key="ReverseTextColor">#212121</Color>
<Color x:Key="TextIconColor">White</Color>
<Color x:Key="BorderColor">#e0e0e0</Color>
<Color x:Key="SecondaryBorderColor">#757575</Color>
<Color x:Key="BackgroundColor">#eeeeee</Color>
<Color x:Key="RegionColor">#ffffff</Color>
<Color x:Key="SecondaryRegionColor">#eeeeee</Color>
<Color x:Key="ThirdlyRegionColor">White</Color>
<Color x:Key="TitleColor">#326cf3</Color>
<Color x:Key="SecondaryTitleColor">#326cf3</Color>
<Color x:Key="DefaultColor">White</Color>
<Color x:Key="DarkDefaultColor">#f5f5f5</Color>
<Color x:Key="AccentColor">#f8491e</Color>
<Color x:Key="DarkAccentColor">#f8491e</Color>
<Color x:Key="DarkMaskColor">#20000000</Color>
<Color x:Key="DarkOpacityColor">#40000000</Color>
<system:UInt32 x:Key="BlurGradientValue">0x99FFFFFF</system:UInt32>
</ResourceDictionary>
二、画刷
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:o="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
>
<SolidColorBrush o:Freeze="True" x:Key="LightPrimaryBrush" Color="{DynamicResource LightPrimaryColor}" />
<LinearGradientBrush o:Freeze="True" x:Key="PrimaryBrush" EndPoint="1,0" StartPoint="0,0">
<GradientStop o:Freeze="True" Color="{DynamicResource PrimaryColor}" Offset="0" />
<GradientStop o:Freeze="True" Color="{DynamicResource DarkPrimaryColor}" Offset="1" />
</LinearGradientBrush>
<SolidColorBrush o:Freeze="True" x:Key="DarkPrimaryBrush" Color="{DynamicResource DarkPrimaryColor}" />
<SolidColorBrush o:Freeze="True" x:Key="PrimaryTextBrush" Color="{DynamicResource PrimaryTextColor}" />
<SolidColorBrush o:Freeze="True" x:Key="SecondaryTextBrush" Color="{DynamicResource SecondaryTextColor}" />
<SolidColorBrush o:Freeze="True" x:Key="ThirdlyTextBrush" Color="{DynamicResource ThirdlyTextColor}" />
<SolidColorBrush o:Freeze="True" x:Key="ReverseTextBrush" Color="{DynamicResource ReverseTextColor}" />
<SolidColorBrush o:Freeze="True" x:Key="TextIconBrush" Color="{DynamicResource TextIconColor}" />
<SolidColorBrush o:Freeze="True" x:Key="BorderBrush" Color="{DynamicResource BorderColor}" />
<SolidColorBrush o:Freeze="True" x:Key="SecondaryBorderBrush" Color="{DynamicResource SecondaryBorderColor}" />
<SolidColorBrush o:Freeze="True" x:Key="BackgroundBrush" Color="{DynamicResource BackgroundColor}" />
<SolidColorBrush o:Freeze="True" x:Key="RegionBrush" Color="{DynamicResource RegionColor}" />
<SolidColorBrush o:Freeze="True" x:Key="SecondaryRegionBrush" Color="{DynamicResource SecondaryRegionColor}" />
<SolidColorBrush o:Freeze="True" x:Key="ThirdlyRegionBrush" Color="{DynamicResource ThirdlyRegionColor}" />
<LinearGradientBrush o:Freeze="True" x:Key="TitleBrush" EndPoint="1,0" StartPoint="0,0">
<GradientStop o:Freeze="True" Color="{DynamicResource TitleColor}" Offset="0" />
<GradientStop o:Freeze="True" Color="{DynamicResource SecondaryTitleColor}" Offset="1" />
</LinearGradientBrush>
<SolidColorBrush o:Freeze="True" x:Key="DefaultBrush" Color="{DynamicResource DefaultColor}" />
<SolidColorBrush o:Freeze="True" x:Key="DarkDefaultBrush" Color="{DynamicResource DarkDefaultColor}" />
<SolidColorBrush o:Freeze="True" x:Key="LightDangerBrush" Color="{DynamicResource LightDangerColor}" />
<LinearGradientBrush o:Freeze="True" x:Key="DangerBrush" EndPoint="1,0" StartPoint="0,0">
<GradientStop o:Freeze="True" Color="{DynamicResource DangerColor}" Offset="0" />
<GradientStop o:Freeze="True" Color="{DynamicResource DarkDangerColor}" Offset="1" />
</LinearGradientBrush>
<SolidColorBrush o:Freeze="True" x:Key="DarkDangerBrush" Color="{DynamicResource DarkDangerColor}" />
<SolidColorBrush o:Freeze="True" x:Key="LightWarningBrush" Color="{DynamicResource LightWarningColor}" />
<LinearGradientBrush o:Freeze="True" x:Key="WarningBrush" EndPoint="1,0" StartPoint="0,0">
<GradientStop o:Freeze="True" Color="{DynamicResource WarningColor}" Offset="0" />
<GradientStop o:Freeze="True" Color="{DynamicResource DarkWarningColor}" Offset="1" />
</LinearGradientBrush>
<SolidColorBrush o:Freeze="True" x:Key="DarkWarningBrush" Color="{DynamicResource DarkWarningColor}" />
<SolidColorBrush o:Freeze="True" x:Key="LightInfoBrush" Color="{DynamicResource LightInfoColor}" />
<LinearGradientBrush o:Freeze="True" x:Key="InfoBrush" EndPoint="1,0" StartPoint="0,0">
<GradientStop o:Freeze="True" Color="{DynamicResource InfoColor}" Offset="0" />
<GradientStop o:Freeze="True" Color="{DynamicResource DarkInfoColor}" Offset="1" />
</LinearGradientBrush>
<SolidColorBrush o:Freeze="True" x:Key="DarkInfoBrush" Color="{DynamicResource DarkInfoColor}" />
<SolidColorBrush o:Freeze="True" x:Key="LightSuccessBrush" Color="{DynamicResource LightSuccessColor}" />
<LinearGradientBrush o:Freeze="True" x:Key="SuccessBrush" EndPoint="1,0" StartPoint="0,0">
<GradientStop o:Freeze="True" Color="{DynamicResource SuccessColor}" Offset="0" />
<GradientStop o:Freeze="True" Color="{DynamicResource DarkSuccessColor}" Offset="1" />
</LinearGradientBrush>
<SolidColorBrush o:Freeze="True" x:Key="DarkSuccessBrush" Color="{DynamicResource DarkSuccessColor}" />
<SolidColorBrush o:Freeze="True" x:Key="AccentBrush" Color="{DynamicResource AccentColor}" />
<SolidColorBrush o:Freeze="True" x:Key="DarkAccentBrush" Color="{DynamicResource DarkAccentColor}" />
<SolidColorBrush o:Freeze="True" x:Key="DarkMaskBrush" Color="{DynamicResource DarkMaskColor}" />
<SolidColorBrush o:Freeze="True" x:Key="DarkOpacityBrush" Color="{DynamicResource DarkOpacityColor}" />
</ResourceDictionary>
三、label
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="LabelBaseStyle" TargetType="Label">
<Setter Property="Foreground" Value="{DynamicResource TextIconBrush}" />
<Setter Property="Background" Value="{DynamicResource RegionBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Height" Value="50" />
<Setter Property="Margin" Value="20" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Label">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.4" />
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="LabelDefault" BasedOn="{StaticResource LabelBaseStyle}" TargetType="Label">
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}" />
<Setter Property="BorderThickness" Value="1" />
</Style>
<Style BasedOn="{StaticResource LabelDefault}" TargetType="Label" />
<Style x:Key="LabelDefault.Small" BasedOn="{StaticResource LabelDefault}" TargetType="Label">
<Setter Property="Height" Value="20" />
<Setter Property="Padding" Value="6,0" />
</Style>
<Style x:Key="LabelPrimary" BasedOn="{StaticResource LabelBaseStyle}" TargetType="Label">
<Setter Property="Background" Value="{DynamicResource PrimaryBrush}" />
</Style>
<Style x:Key="LabelPrimary.Small" BasedOn="{StaticResource LabelPrimary}" TargetType="Label">
<Setter Property="Height" Value="20" />
<Setter Property="Padding" Value="6,0" />
</Style>
<Style x:Key="LabelSuccess" BasedOn="{StaticResource LabelBaseStyle}" TargetType="Label">
<Setter Property="Background" Value="{DynamicResource SuccessBrush}" />
</Style>
<Style x:Key="LabelSuccess.Small" BasedOn="{StaticResource LabelSuccess}" TargetType="Label">
<Setter Property="Height" Value="20" />
<Setter Property="Padding" Value="6,0" />
</Style>
<Style x:Key="LabelInfo" BasedOn="{StaticResource LabelBaseStyle}" TargetType="Label">
<Setter Property="Background" Value="{DynamicResource InfoBrush}" />
</Style>
<Style x:Key="LabelInfo.Small" BasedOn="{StaticResource LabelInfo}" TargetType="Label">
<Setter Property="Height" Value="20" />
<Setter Property="Padding" Value="6,0" />
</Style>
<Style x:Key="LabelWarning" BasedOn="{StaticResource LabelBaseStyle}" TargetType="Label">
<Setter Property="Background" Value="{DynamicResource WarningBrush}" />
</Style>
<Style x:Key="LabelWarning.Small" BasedOn="{StaticResource LabelWarning}" TargetType="Label">
<Setter Property="Height" Value="20" />
<Setter Property="Padding" Value="6,0" />
</Style>
<Style x:Key="LabelDanger" BasedOn="{StaticResource LabelBaseStyle}" TargetType="Label">
<Setter Property="Background" Value="{DynamicResource DangerBrush}" />
</Style>
<Style x:Key="LabelDanger.Small" BasedOn="{StaticResource LabelDanger}" TargetType="Label">
<Setter Property="Height" Value="20" />
<Setter Property="Padding" Value="6,0" />
</Style>
</ResourceDictionary>
四、Demo
<UserControl x:Class="lyrics.ui.Demo.Brush.BrushUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:lyrics.ui.Demo.Brush"
mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="800">
<WrapPanel>
<Label Content="PrimaryBrush" Style="{StaticResource LabelPrimary}"/>
<Label Content="DarkPrimaryBrush" Background="{DynamicResource DarkPrimaryBrush}" Foreground="White" BorderThickness="0"/>
<Label Content="DangerBrush" Style="{StaticResource LabelDanger}"/>
<Label Content="DarkDangerBrush" Background="{DynamicResource DarkDangerBrush}" Foreground="White" BorderThickness="0"/>
<Label Content="WarningBrush" Style="{StaticResource LabelWarning}"/>
<Label Content="DarkWarningBrush" Background="{DynamicResource DarkWarningBrush}" Foreground="White" BorderThickness="0"/>
<Label Content="InfoBrush" Style="{StaticResource LabelInfo}"/>
<Label Content="DarkInfoBrush" Background="{DynamicResource DarkInfoBrush}" Foreground="White" BorderThickness="0"/>
<Label Content="SuccessBrush" Style="{StaticResource LabelSuccess}"/>
<Label Content="DarkSuccessBrush" Background="{DynamicResource DarkSuccessBrush}" Foreground="White" BorderThickness="0"/>
<Label Content="AccentBrush" Background="{DynamicResource AccentBrush}" Foreground="White" BorderThickness="0"/>
<Label Content="DarkAccentBrush" Background="{DynamicResource DarkAccentBrush}" Foreground="White" BorderThickness="0"/>
<Label Content="PrimaryTextBrush" Background="{DynamicResource PrimaryTextBrush}" Foreground="{DynamicResource ThirdlyTextBrush}"/>
<Label Content="SecondaryTextBrush" BorderThickness="0" Background="{DynamicResource SecondaryTextBrush}" Foreground="White"/>
<Label Content="ThirdlyTextBrush" BorderThickness="0" Background="{DynamicResource ThirdlyTextBrush}" Foreground="White"/>
<Label Content="ReverseTextBrush" BorderThickness="0" Background="{DynamicResource ReverseTextBrush}" Foreground="White"/>
<Label Content="TextIconBrush" Background="{DynamicResource TextIconBrush}" Foreground="{DynamicResource ReverseTextBrush}"/>
<Label Content="BorderBrush" BorderThickness="0" Background="{DynamicResource BorderBrush}" Foreground="{DynamicResource PrimaryTextBrush}"/>
<Label Content="SecondaryBorderBrush" BorderThickness="0" Background="{DynamicResource SecondaryBorderBrush}" Foreground="White"/>
<Label Content="BackgroundBrush" BorderThickness="0" Background="{DynamicResource BackgroundBrush}" Foreground="{DynamicResource ReverseTextBrush}"/>
<Label Content="RegionBrush" Background="{DynamicResource RegionBrush}" Foreground="{DynamicResource PrimaryTextBrush}"/>
<Label Content="SecondaryRegionBrush" BorderThickness="0" Background="{DynamicResource SecondaryRegionBrush}" Foreground="{DynamicResource PrimaryTextBrush}"/>
<Label Content="ThirdlyRegionBrush" Background="{DynamicResource ThirdlyRegionBrush}" Foreground="{DynamicResource PrimaryTextBrush}"/>
<Label Content="TitleBrush" BorderThickness="0" Background="{DynamicResource TitleBrush}" Foreground="White"/>
<Label Content="DefaultBrush" Background="{DynamicResource DefaultBrush}" Foreground="{DynamicResource PrimaryTextBrush}"/>
<Label Content="DarkDefaultBrush" BorderThickness="0" Background="{DynamicResource DarkDefaultBrush}" Foreground="{DynamicResource PrimaryTextBrush}"/>
<Label Content="DarkMaskBrush" BorderThickness="0" Background="{DynamicResource DarkMaskBrush}" Foreground="{DynamicResource PrimaryTextBrush}"/>
<Label Content="DarkOpacityBrush" BorderThickness="0" Background="{DynamicResource DarkOpacityBrush}" Foreground="White"/>
</WrapPanel>
</UserControl>
五、效果
