WPF -- 叠加多个 Style 的效果
程序员文章站
2022-05-17 22:18:00
...
效果:
XAML代码:
<Grid> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <Grid.Resources> <Style TargetType="Button" x:Key="Bold"> <Setter Property="FontWeight" Value="Bold" /> </Style> <Style TargetType="Button" BasedOn="{StaticResource Bold}"> </Style> <Style TargetType="Button" BasedOn="{StaticResource Bold}" x:Key="Yellow"> <Setter Property="Background" Value="Yellow" /> </Style> </Grid.Resources> <Button Grid.Row="0" Content="Bold" /> <Button Grid.Row="1" Content="Bold + Yellow" Style="{StaticResource Yellow}" /> </Grid>