WPF CheckBox 自定义样式
2024-10-10 12:49:30
WPF 自定义样式。CheckBox
<Style x:Key="EmptyCheckBox" TargetType="CheckBox">
<Setter Property="Focusable" Value="False"/>
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Height" Value="32"/>
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="CheckBox">
<Grid Background="Transparent" Cursor="Hand">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Disabled" />
<VisualState x:Name="Normal" />
<VisualState x:Name="MouseOver" />
<VisualState x:Name="Pressed" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Image Source="/FZHotel.MatroUIApp;component/Images/Button/check_ok.png"></Image>
<ContentPresenter Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsChecked" Value="False">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="CheckBox">
<Grid Background="Transparent" Cursor="Hand">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Disabled" />
<VisualState x:Name="Normal" />
<VisualState x:Name="MouseOver" />
<VisualState x:Name="Pressed" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Image Source="/FZHotel.MatroUIApp;component/Images/Button/check_cancel.png"></Image>
<ContentPresenter Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
最新文章
- 第一章-第十一题(请问 “软件” 和 “软件工程” 这些词汇是如何出现的 - 何时、何地、何人)--By 侯伟婷
- C语言 06 指针
- AEAI CRM客户关系管理升级说明
- 【转】java正则表达式
- [转载] 动态链接库dll的 静态加载 与 动态加载
- A题笔记(8)
- 《Mathematical Olympiad——组合数学》——操作和游戏
- 连接远程hbase长时间等待问题
- maven 编
- C# lesson2
- [国嵌笔记][017][Makefile工程管理]
- 微信小程序之菜鸟入门教学(二)
- Eclipse工具常用快捷键
- VUE-开发工具VSCode
- Oracle列转行函数LISTAGG()
- Dell Technology Summit(2018.10.17)
- 13.BeanUtils组件-基础.md
- hdu 1.3.2 Moving Tables
- 学习Spring Boot:(十三)配置 Shiro 权限认证
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) A. Checking the Calendar 水题