WPF 样式
程序员文章站
2022-07-13 22:55:01
...
Style
定义一个普通的Style
<Window.Resources>
<Style x:Key="DefaultBtn" TargetType="Button">
<Setter Property="Foreground" Value="Red"></Setter>
<Setter Property="FontSize" Value="30"></Setter>
</Style>
</Window.Resources>
<Grid>
<Button Width="100" Height="100" Content="heihei" Style="{StaticResource DefaultBtn}" />
</Grid>
定义一个可继承的Style
<Window.Resources>
<Style x:Key="BaseBtn" TargetType="Button">
<Setter Property="Foreground" Value="Red"></Setter>
<Setter Property="FontSize" Value="30"></Setter>
</Style>
<Style x:Key="DefaultBtn" BasedOn="{StaticResource BaseBtn}" TargetType="Button">
<Setter Property="Width" Value="200"></Setter>
</Style>
</Window.Resources>
<Grid>
<StackPanel>
<Button Width="100" Height="100" Content="heihei" Style="{StaticResource DefaultBtn}" />
</StackPanel>
</Grid>
上一篇: WPF Combobox Style
下一篇: WPF 最简逻辑实现多指顺滑的笔迹书写