WPF样式
程序员文章站
2022-07-13 22:54:55
...
<!--样式设置-->
<Window.Resources>
<Style x:Key="defaultstyle1" TargetType="Button">
<Setter Property="Background" Value="Red" />
</Style>
<!--继承背景颜色-->
<Style x:Key="defaultstyle2" TargetType="Button" BasedOn="{StaticResource defaultstyle1}">
<Setter Property="FontSize" Value="30" />
</Style>
</Window.Resources>
<Grid ShowGridLines="True">
<StackPanel>
<Button Style="{StaticResource defaultstyle2}" Content="Hello" Width="80" Height="40" />
<Button Style="{StaticResource defaultstyle2}" Content="Hello" Width="80" Height="40" />
<Button Style="{StaticResource defaultstyle2}" Content="Hello" Width="80" Height="40" />
<Button Style="{StaticResource defaultstyle2}" Content="Hello" Width="80" Height="40" />
</StackPanel>
</Grid>