WPF RadioButton & CheckBox Style

<Style TargetType="CheckBox">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="CheckBox">
<Border x:Name="bd" BorderBrush="Gray" BorderThickness="1" Padding="5" SnapsToDevicePixels="True" Background="#02000000">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
<ContentPresenter Margin="0 0 10 0" Content="{TemplateBinding Content}" VerticalAlignment="Center"/>
<Border x:Name="outterBd" Margin="-5" Padding="2" BorderBrush="Gray" BorderThickness="1 0 0 0" Grid.Column="1">
<Border x:Name="innerBd" Background="LightGray" Grid.Column="1">
<Border x:Name="slider" Margin="5 -2 30 -2" Background="#FF4D4D4D"/>
</Border>
</Border>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="bd" Property="BorderBrush" Value="{StaticResource ToolBarBackgroundBrush}"/>
<Setter TargetName="outterBd" Property="BorderBrush" Value="{StaticResource ToolBarBackgroundBrush}"/>
</Trigger>
<Trigger Property="IsChecked" Value="true">
<Setter Property="Margin" Value="30 -2 5 -2" TargetName="slider"/>
<Setter Property="Background" Value="Gray" TargetName="innerBd"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="RadioButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<Border Margin="-1 0 0 0" SnapsToDevicePixels="True" x:Name="bd" BorderBrush="Gray" BorderThickness="1" Padding="5" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}" Background="#02000000">
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center" Content="{TemplateBinding Content}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="bd" Property="BorderBrush" Value="{StaticResource ToolBarBackgroundBrush}"/>
</Trigger>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="bd" Property="Background">
<Setter.Value>
<SolidColorBrush Color="LightGray"/>
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
WPF RadioButton & CheckBox Style的更多相关文章
- 背水一战 Windows 10 (33) - 控件(选择类): ListBox, RadioButton, CheckBox, ToggleSwitch
[源码下载] 背水一战 Windows 10 (33) - 控件(选择类): ListBox, RadioButton, CheckBox, ToggleSwitch 作者:webabcd 介绍背水一 ...
- WPF系列-CheckBox
自定义样式1 效果: 代码: <!-- CheckBox的样式 --> <Style TargetType="{x:Type CheckBox}"> < ...
- WPF中的Style
一.Style基础知识 构成Style最重要的两种元素是Setter和Trigger Setter类帮助我们设置控件的静态外观风格 Trigger类帮助我们设置控件的行为风格 Setter类的Prop ...
- WPF 带CheckBox、图标的TreeView
WPF 带CheckBox.图标的TreeView 在WPF实际项目开发的时候,经常会用到带CheckBox的TreeView,虽然微软在WPF的TreeView中没有提供该功能,但是微软在WPF中提 ...
- 重新想象 Windows 8 Store Apps (2) - 控件之按钮控件: Button, HyperlinkButton, RepeatButton, ToggleButton, RadioButton, CheckBox, ToggleSwitch
原文:重新想象 Windows 8 Store Apps (2) - 控件之按钮控件: Button, HyperlinkButton, RepeatButton, ToggleButton, Rad ...
- WPF中CheckBox三种状态打勾打叉和滑动效果
本文分为两个demo, 第一个demo实现checkBox的打叉或打勾的效果: 第二个demo部分实现checkBox的滑动效果. Demo1: wpf的CheckBox支持三种状态,但是美中不足的是 ...
- WPF:CheckBox竖向的滑块效果
原文:WPF:CheckBox竖向的滑块效果 之前做了一个横向的滑块效果,<WPF:CheckBox滑块效果>,其实我觉得那个不好看,今天又做了一个竖向的玩. <Style Targ ...
- WPF把CheckBox的文字放到左边,开关在右边
原文:WPF把CheckBox的文字放到左边,开关在右边 效果 实现 这篇文章给了一个不错的参考方案. http://www.codeproject.com/Articles/19141/WPF-Ch ...
- WPF样式(Style)入门
原文:WPF样式(Style)入门 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/qq_34802416/article/details/78231 ...
随机推荐
- curl测试puppet http api接口
---恢复内容开始--- 基于证书密钥对 curl --cert /etc/puppetlabs/puppet/ssl/certs/master.puppet.org.pem --key /etc/p ...
- cat、cp命令
cat是查看文件内容, cp –cp是连目录及件文件都拷贝 cp是拷贝文件 a.txt里的内容是, abc def ghi cat a.txt |grep –v ghi 得到结果, abc def h ...
- poj 2828 Buy Tickets【线段树单点更新】【逆序输入】
Buy Tickets Time Limit: 4000MS Memory Limit: 65536K Total Submissions: 16273 Accepted: 8098 Desc ...
- nyoj 123 士兵杀敌(四) 树状数组【单点查询+区间修改】
士兵杀敌(四) 时间限制:2000 ms | 内存限制:65535 KB 难度:5 描述 南将军麾下有百万精兵,现已知共有M个士兵,编号为1~M,每次有任务的时候,总会有一批编号连在一起人请战 ...
- hdoj1754 I Hate It【线段树区间最大值维护+单点更新】
I Hate It Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- 8-3-COMPETITION
链接:8.3比赛 这次是动态规划里的LCS,LIS,LCIS专场....... A.Common Subsequence 就是:给出两个字符串,求出其中的最长公共子序列的长度~LCS 代码: //me ...
- HTML5实践之歌词同步播放器
歌曲播放我们会发现他的兼容性不是很好,譬如IE上能播放的flash播放器,再firfox或者chrome上就不是很好的应用了,因为有插件的阻碍!HTML5的出现让这一切成为了可能,但是播放器虽然播放了 ...
- CSS 边框 阴影 效果
CSS 边框 阴影 效果 以下将css实现阴影效果,以便须要朋友们,直接上代码 #shadow1{ width: 200px; height: 100px; color: white; backgro ...
- group by是什么意思 mysql中
mysql语法中group by是什么意思? 在百度中搜索半天,最后找到一篇解释比较好的(不是博文,是百度知道,很郁闷那么多网友怎么就没人解释的清楚),链接如下: http://zhidao.baid ...
- hadoop错误org.apache.hadoop.mapred.TaskAttemptListenerImpl Progress of TaskAttempt
错误: org.apache.hadoop.mapred.TaskAttemptListenerImpl: Progress of TaskAttempt 原因: 错误很明显,磁盘空间不足,但郁闷的是 ...