当前位置:网站首页>WPF RadioButton 样式 (1)
WPF RadioButton 样式 (1)
2022-07-19 16:50:00 【小慧哥】
界面
<RadioButton x:Name="radioButton" IsChecked="True" Content="界面" HorizontalAlignment="Left" Height="90" Margin="100,334,0,0" VerticalAlignment="Top" Width="60" Style="{DynamicResource RadioButtonOISStyle}"/>
<RadioButton x:Name="radioButton_Copy" Content="用户管理" HorizontalAlignment="Right" Height="90" Margin="0,334,100,0" VerticalAlignment="Top" Width="70" Style="{DynamicResource RadioButtonAdminStyle}"/>
样式
<Style x:Key="RadioButtonOISStyle" TargetType="{x:Type RadioButton}">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="Background" Value="{StaticResource CheckRadioFillNormal}"/>
<Setter Property="BorderBrush" Value="{StaticResource CheckRadioStrokeNormal}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RadioButton}">
<Grid Margin="0,0,0,-4.11" Width="60" Height="Auto">
<Grid.RowDefinitions>
<RowDefinition Height="31*"/>
<RowDefinition Height="11*"/>
</Grid.RowDefinitions>
<!--背景颜色 透明度 边框弧度-->
<Rectangle x:Name="rectangle" Fill="{x:Null}" Stroke="{x:Null}" Opacity="1" RadiusX="0" RadiusY="0" StrokeThickness="0" Grid.RowSpan="1"/>
<Image x:Name="image" Source="/OIS;component/Resources/Images/oisB.png" Grid.RowSpan="1" Height="Auto" HorizontalAlignment="Center" Width="60" Margin="0,4.5" />
<!--字体颜色, 字体大小-->
<TextBlock x:Name="textBlock" Margin="0" TextWrapping="Wrap" Text="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Stretch" Height="22" FontSize="16" Foreground="#FFACADAE" Grid.RowSpan="1" Grid.Row="1" Width="33"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="GroupName" Value=""/>
<Trigger Property="GroupName" Value=""/>
<!--鼠标点击触发器, 背景颜色-->
<Trigger Property="IsChecked" Value="True">
<Setter Property="Opacity" TargetName="rectangle" Value="1"/>
<Setter Property="Source" TargetName="image" Value="/OIS;component/Resources/Images/oisA.png"/>
<Setter Property="Foreground" TargetName="textBlock" Value="#FF1AB394"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="RadioButtonAdminStyle" TargetType="{x:Type RadioButton}">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="Background" Value="{StaticResource CheckRadioFillNormal}"/>
<Setter Property="BorderBrush" Value="{StaticResource CheckRadioStrokeNormal}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RadioButton}">
<Grid Margin="0,0,0,-4.11" Width="70" Height="Auto">
<Grid.RowDefinitions>
<RowDefinition Height="31*"/>
<RowDefinition Height="11*"/>
</Grid.RowDefinitions>
<!--背景颜色 透明度 边框弧度-->
<Rectangle x:Name="rectangle" Fill="{x:Null}" Stroke="{x:Null}" Opacity="1" RadiusX="0" RadiusY="0" StrokeThickness="0" Grid.RowSpan="1"/>
<Image x:Name="image" Source="/OIS;component/Resources/Images/AdminB.png" Grid.RowSpan="1" Height="Auto" HorizontalAlignment="Center" Width="60" Margin="0,4.5" />
<!--字体颜色, 字体大小-->
<TextBlock x:Name="textBlock" Margin="0" TextWrapping="Wrap" Text="{TemplateBinding Content}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="22" FontSize="16" Foreground="#FFACADAE" Grid.RowSpan="1" Grid.Row="1" Width="Auto"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="GroupName" Value=""/>
<Trigger Property="GroupName" Value=""/>
<!--鼠标点击触发器, 背景颜色-->
<Trigger Property="IsChecked" Value="True">
<Setter Property="Opacity" TargetName="rectangle" Value="1"/>
<Setter Property="Source" TargetName="image" Value="/OIS;component/Resources/Images/adminA.png"/>
<Setter Property="Foreground" TargetName="textBlock" Value="#FF1AB394"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
边栏推荐
猜你喜欢
odoo基础开发之CURD(增、删、查、改)
Matlab填充影像中的无效值
How to solve the user name enumeration vulnerability
文件操作-
Matlab TRMM_3B42数据格式转换(nc转tif,附代码)
MATLAB实现LMDI分解方法(含零值处理)
信通院《分布式存储发展白皮书(2022年)》发布:华云数据参与编制 为产业发展提速换挡
Fill polygon with MATLAB
欧洲气象中心资料(ERA)下载方法
Go fastdfs distributed file system construction (implementation sorting)
随机推荐
Quickly extract tables from PDF files
数据查询必备技能SQL调优:Mysql什么情况下不走索引
第七章:集合
The power behind | strengthen the construction of digital government, and Huayun data helps the Civil Affairs Department of a province in Central China improve its convenience service capacity
华云数据荣获可持续技术创新杰出贡献企业
Arcgis/arcpy convert floating-point grid to integer grid
JSR303数据校验
MATLAB绘制环形比例图
JVM 上数据处理语言的竞争:Kotlin, Scala 和 SPL
行业首个「视频直播技术最佳实践图」发布!
地学学术资源(常用数据及其下载地址)
Pycharm Debug错误“Process finished with exit code -1073741819 (0xC0000005)”解决方案
【问题解决】端口号被占用问题
MLX90640 红外热成像仪测温模块简要介绍说明
信通院《分布式存储发展白皮书(2022年)》发布:华云数据参与编制 为产业发展提速换挡
Summary of project experience - send it to the friends of the testing post who are doing the project
给自己搭建一个极致简陋但足够好用的羞图站
What happens to cross domain? Solutions to cross domain problems
Geoscience academic resources (common data and their download addresses)
oracle建表语句模板