标签:cat get ffffff fonts margin component pac idt button
1、添加“资源字典”;
工程名称:WpfApp1
新建Styles文件夹;
创建“Dictionary1.xaml”的文件;
2、编辑样式;
<SolidColorBrush x:Key="MainColor">#FF000000</SolidColorBrush> <SolidColorBrush x:Key="MainColor1">#FFFFFFFF</SolidColorBrush> <Style TargetType="Button"> <Setter Property="Background" Value="Blue"/> </Style> <Style TargetType="TextBox"> <Setter Property="FontFamily" Value="微软雅黑"/> <Setter Property="FontSize" Value="23"/> </Style>
3、在App.xaml中引用样式
<Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack://application:,,,/WpfApp1;component/Styles/Dictionary1.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources>
4、元素上添加样式
<Button Content="主题颜色" Width="100" Height="40" Margin="545,82,155,328"/> <Button Content="主题颜色" Width="100" Height="40" Margin="545,127,155,283"/> <Button Content="外部样式" Width="100" Height="40" Margin="144,270,556,140" Background="{StaticResource MainColor}" Foreground="{StaticResource MainColor1}"/>
标签:cat get ffffff fonts margin component pac idt button
原文地址:https://www.cnblogs.com/suenihy/p/11368447.html