WPF 基础控件之 RadioButton 样式

其他基础控件

1.Window
2.Button
3.CheckBox
4.ComboBox
5.DataGrid
6.DatePicker
7.Expander
8.GroupBox
9.ListBox
10.ListView
11.Menu
12.PasswordBox
13.TextBox
14.ProgressBar

RadioButton  实现下面的效果

6307950d5d77f68d10b06ba98c15c849.png

1)RadioButton来实现动画;

  • Border嵌套 Ellipse并设置ScaleTransform ScaleX= 0 ScaleY =0 ,当选中CheckedScaleX= 0.4 ScaleY =0.4

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:wpfs="clr-namespace:WPFDevelopers.Minimal.Helpers"><ResourceDictionary.MergedDictionaries><ResourceDictionary Source="../Themes/Basic/ControlBasic.xaml"/><ResourceDictionary Source="../Themes/Basic/Animations.xaml"/></ResourceDictionary.MergedDictionaries><Style TargetType="{x:Type RadioButton}" BasedOn="{StaticResource ControlBasicStyle}"><Setter Property="FocusVisualStyle" Value="{x:Null}"/><Setter Property="Background" Value="{DynamicResource WhiteSolidColorBrush}"/><Setter Property="BorderThickness" Value="1"/><Setter Property="Cursor" Value="Hand"/><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type RadioButton}"><Grid SnapsToDevicePixels="True"><Grid.ColumnDefinitions><ColumnDefinition Width="Auto"/><ColumnDefinition Width="*"/></Grid.ColumnDefinitions><Border CornerRadius="{Binding ElementName=PART_Border,Path=CornerRadius}"Background="{Binding ElementName=PART_Border,Path=Background}"Margin="1,1,2,1"><Border x:Name="PART_Border" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="100"HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"VerticalAlignment="{TemplateBinding VerticalContentAlignment}"><Border.BorderBrush><SolidColorBrush Color="{DynamicResource BaseColor}"/></Border.BorderBrush><Grid Width="16" Height="16"><Ellipse x:Name="PART_Ellipse" Fill="{DynamicResource WhiteSolidColorBrush}" MinWidth="6" MinHeight="6"RenderTransformOrigin=".5,.5"><Ellipse.RenderTransform><ScaleTransform ScaleX="0" ScaleY="0"/></Ellipse.RenderTransform></Ellipse></Grid></Border></Border><ContentPresenter x:Name="PART_ContentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="1" ContentStringFormat="{TemplateBinding ContentStringFormat}" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}"RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"TextElement.Foreground="{DynamicResource PrimaryTextSolidColorBrush}"/><VisualStateManager.VisualStateGroups><VisualStateGroup x:Name="CheckStates"><VisualState x:Name="Unchecked"/><VisualState x:Name="Indeterminate"/><VisualState x:Name="Checked"><Storyboard><!--<ColorAnimation Storyboard.TargetName="PART_ContentPresenter"Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"To="{DynamicResource PrimaryPressedColor}"Duration="00:00:.1"/><ColorAnimation Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" Storyboard.TargetName="PART_Border"To="{DynamicResource PrimaryPressedColor}" Duration="00:00:.1"/><ColorAnimation Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="PART_Border"To="{DynamicResource PrimaryPressedColor}" Duration="00:00:.1"/>--><!--<ThicknessAnimation Storyboard.TargetName="PART_Border"Storyboard.TargetProperty="BorderThickness" To="0,0,0,0" Duration="00:00:.1"/>--><DoubleAnimation Storyboard.TargetName="PART_Ellipse"Storyboard.TargetProperty="(Ellipse.RenderTransform).(ScaleTransform.ScaleX)" To=".4" Duration="00:00:.3"EasingFunction="{StaticResource ExponentialEaseOut}"/><DoubleAnimation Storyboard.TargetName="PART_Ellipse"Storyboard.TargetProperty="(Ellipse.RenderTransform).(ScaleTransform.ScaleY)" To=".4" Duration="00:00:.3"EasingFunction="{StaticResource ExponentialEaseOut}"/></Storyboard></VisualState></VisualStateGroup></VisualStateManager.VisualStateGroups></Grid><ControlTemplate.Triggers><!--<Trigger Property="IsEnabled" Value="False"><Setter Property="Opacity" Value="{StaticResource EnabledOpacity}" /></Trigger>--><Trigger Property="IsChecked" Value="True"><Setter Property="Background" TargetName="PART_Border" Value="{DynamicResource PrimaryNormalSolidColorBrush}"/><Setter Property="BorderBrush" TargetName="PART_Border" Value="{DynamicResource PrimaryNormalSolidColorBrush}"/><Setter Property="TextElement.Foreground" TargetName="PART_ContentPresenter" Value="{DynamicResource PrimaryNormalSolidColorBrush}"/></Trigger><MultiTrigger><MultiTrigger.Conditions><Condition Property="IsChecked" Value="False" /><Condition Property="IsMouseOver" Value="True" /></MultiTrigger.Conditions><Setter Property="BorderBrush" TargetName="PART_Border" Value="{DynamicResource PrimaryMouseOverSolidColorBrush}"/><!--<MultiTrigger.EnterActions><BeginStoryboard x:Name="PART_BeginStoryboard"><Storyboard><ColorAnimation Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="PART_Border"To="{StaticResource PrimaryPressedColor}" Duration="00:00:.1"/></Storyboard></BeginStoryboard></MultiTrigger.EnterActions><MultiTrigger.ExitActions><RemoveStoryboard BeginStoryboardName="PART_BeginStoryboard"></RemoveStoryboard></MultiTrigger.ExitActions>--></MultiTrigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter></Style>
</ResourceDictionary>

2)Styles.RadioButton.xaml 代码如下;

<WrapPanel Margin="0,10"><RadioButton Content="Option A"/><RadioButton Content="Option B" Margin="10,0" IsChecked="True"/><RadioButton Content="Option C" IsEnabled="False"/></WrapPanel>

Nuget Install-Package WPFDevelopers.Minimal

73986042420810b4f2b53913bd0b02c4.gif

[1][2]

参考资料

[1]

GitHub: https://github.com/WPFDevelopersOrg

[2]

Gitee: https://gitee.com/WPFDevelopersOrg

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/287130.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

对归并排序进行c语言编程实现,归并排序及C语言实现

排序系列之(1)归并排序及C语言实现有很多算法在结构上是递归的&#xff1a;为了解决一个给定的问题&#xff0c;算法需要一次或多次递归的调用其本身来解决相关的问题。这些算法通常采用分治策略&#xff1a;将原问题划分成n个规模较小而结构与原问题相似的子问题&#xff1b;递…

Android之提示错误Can not perform this action after onSaveInstanceState

1 问题 主页面3个Fragment,在第三个Fragment里面开启了Activity之后,然后想跳到第一个Fragment代码如下 /*** 展示Fragment*/private fun showFragment(fragment: Fragment) {if (currentFragment !== fragment) {val transaction: FragmentTransaction = supportFragmentMa…

《看聊天记录都学不会C#?太菜了吧》(6)多晦涩的专业术语原来都会那么简单

本系列文章将会以通俗易懂的对话方式进行教学&#xff0c;对话中将涵盖了新手在学习中的一般问题。此系列将会持续更新&#xff0c;包括别的语言以及实战都将使用对话的方式进行教学&#xff0c;基础编程语言教学适用于零基础小白&#xff0c;之后实战课程也将会逐步更新。 若…

【Python可视化】利用Numpy绘制各种统计图表

NumPy简介 NumPy(Numerical Python) 是 Python 语言的一个扩展程序库,支持大量的维度数组与矩阵运算,此外也针对数组运算提供大量的数学函数库。 NumPy 的前身 Numeric 最早是由 Jim Hugunin 与其它协作者共同开发,2005 年,Travis Oliphant 在 Numeric 中结合了另一个同性质…

这个设计原则,你认同吗?

前言我们都知道依赖注入的方式常见的主要有三种构造函数注入属性注入接口注入在大名鼎鼎的Spring框架中大量使用属性注入的方式&#xff0c;属性注入的方式写起来那是真的爽&#xff1b;而在Asp.NetCore中则不支持属性注入&#xff0c;如果不使用第三方库&#xff0c;我们就只能…

Android之提示Unable to instantiate fragment***MyLikeFragment .could not find Fragment constructor

1 问题 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.appsinnova.android.keepdrop/com.appsinnova.android.keepdrop.account.favorite.activity.MyLikeActivity}: androidx.fragment.app.Fragment$InstantiationException: Unable to instantiat…

SQLServer2008-镜像数据库实施手册(双机)SQL-Server2014同样适用

SQL Server2008R2-镜像数据库实施手册(双机)SQL Server2014同样适用 一、配置主备机 1、 服务器基本信息 主机名称为&#xff1a;HOST_A&#xff0c;IP地址为&#xff1a;192.168.1.155 备机名称为&#xff1a;HOST_B&#xff0c;IP地址为&#xff1a;192.168.1.156 二、主备实…

一万字一篇文20分钟学会C语言和Python,十四年编程经验老鸟传授经验之道

前言 昨天在直播中有粉丝问我如何快速的对编程语言入门&#xff0c;我想这个问题是有必要让大家知道的&#xff0c;相必也有很多新手对于如何快速完成编程语言的入门学习很感兴趣&#xff0c;本篇文将会使用 C 语言以及 Python 为例&#xff0c;做出对比&#xff0c;让大家对编…

C语言基于dag的基本块优化,基于dag的基本块优化参考.docx

基于dag的基本块优化参考基于DAG的基本块优化1&#xff0e;实验目的与任务了解基本块的DAG表示及其应用&#xff0c;掌握局部优化的基本方法。2&#xff0e;实验要求设计一个转换程序&#xff0c;把由四元式序列表示的基本块转换为DAG&#xff0c;并在构造DAG的过程中&#xff…

【Python可视化】Windows 10系统上Pyecharts安装教程

简单的Python库&#xff0c;如Numpy&#xff0c;可以直接在PyCharm中自动下载并安装。 同添加Python环境变量一样&#xff0c;需要先添加pip环境变量。pip位于C:\Python27\ArcGIS10.8\Scripts路径下。 WinR→cmd&#xff1a; 安装完成&#xff01;

使用.Net分析.Net达人挑战赛参与情况

背景C#是我2012年在大学课程中接触的&#xff0c;.NET Framework 我也一直使用至今。从2014年.NET 开源&#xff0c;2019年发布.NET Core 3 的时候&#xff0c;公司刚好有 Nvidia Jetson 平台 Linux 嵌入式设备的开发任务&#xff0c;.NET 又刚是适用于 Windows, Linux, 和 mac…

Android之RecycleView实现指定范围的拖动效果

1 问题 在RecycleView里面实现指定位置的拖动效果,(这里是实现线性布局的,不是网格布局的) @Overridepublic boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {Log.i(TAG, "onMove viewHolder.getA…

十分钟如何学会C语言?掌握规律举一反三考试提50分!

前言 上周写了一篇 20 分钟学会 C 语言与Python的文章——《一万字一篇文20分钟学会C语言和Python&#xff0c;十四年编程经验老鸟传授经验之道》&#xff0c;之后见粉丝转了一个话题“十分钟如何学会C语言”&#xff0c;我就在想是否能够十分钟呢&#xff1f;答案是可以的&am…

异常何时去捕获

在业务逻辑层捕获异常。 工具类中不可处理异常&#xff0c;有异常要向外抛&#xff01;&#xff01;&#xff01;转载于:https://www.cnblogs.com/swbzmx/p/5643756.html

c语言在win8系统不兼容,Win8系统中存在不兼容软件如何解决?

最近有刚升级Win8系统的用户反映&#xff0c;FastStone Capture截图软件在Win7系统中可以兼容&#xff0c;正常打开&#xff0c;可是在Win8系统中就不能兼容了&#xff0c;这让用户非常烦恼。那么&#xff0c;Win8系统中存在不兼容软件如何解决呢&#xff1f;下面&#xff0c;我…

Python 3.6出现报错解决方案:No Python 3.6 installation was detected,无法卸载Python

卸载Python 3.6时错误提示&#xff0c;No Python 3.6 installation was detected。 解决办法是&#xff0c;先右键→更改→Repair。 然后再卸载&#xff0c;完成&#xff01;

Android之解决ScrollView嵌套RecycleView导致滑动冲突或者显示不全的问题

1 问题 ScrollView嵌套RecycleView导致滑动冲突或者显示不全的问题 2 解决办法 1&#xff09;、ScrollView替换成普通布局&#xff0c;然后RecycleView用的BaseMultiItemQuickAdapter多布局来写&#xff0c;也就是整个页面只有一个RecycleView&#xff0c;用来取代ScrollView…

MASA Auth - 权限设计

权限术语Subject&#xff1a;用户&#xff0c;用户组Action&#xff1a;对Object的操作&#xff0c;如增删改查等Object&#xff1a;权限作用的对象&#xff0c;也可以理解为资源Effect&#xff1a;规则的作用&#xff0c;如允许&#xff0c;拒绝Condition&#xff1a;生效条件…

iOS js oc相互调用(JavaScriptCore)

http://blog.csdn.net/lwjok2007/article/details/47058795转载于:https://www.cnblogs.com/wlsxmhz/p/5645985.html

Android怎么自定义listview布局,Android ListView自定义布局

编辑&#xff1a;找一个 “开箱即用” 的帖子的末尾例子&#xff01;因为你看到多行受到影响我猜它有些事情要做系统如何回收资源&#xff0c;也许对Button的引用是不明确的。我不确定我在哪里选择了这种做法(Android教程或我们以前的开发人员通过这些教程学习了Android)。然而…