日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > asp.net >内容正文

asp.net

WPF 基础控件之CheckBox样式

發布時間:2023/12/4 asp.net 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 WPF 基础控件之CheckBox样式 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

WPF開發者QQ群:340500857

?? ??? 由于微信群人數太多入群請添加小編微信號

?yanjinhuawechatW_Feng_aiQ?邀請入群

?需備注WPF開發者?

?PS:有更好的方式歡迎推薦。

支持Nuget

Install-Package WPFDevelopers.Minimal -Version 3.0.0

01

代碼如下

一、創建?Styles.CheckBox.xaml?代碼如下。

<ResourceDictionary?xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:sys="clr-namespace:System;assembly=mscorlib"><ResourceDictionary.MergedDictionaries><ResourceDictionary?Source="../Themes/Basic/ControlBasic.xaml"/><ResourceDictionary?Source="../Themes/Basic/Animations.xaml"/></ResourceDictionary.MergedDictionaries><Style?TargetType="{x:Type?CheckBox}"?BasedOn="{StaticResource?ControlBasicStyle}"><Setter?Property="FocusVisualStyle"?Value="{x:Null}"?/><Setter?Property="Cursor"?Value="Hand"/><Setter?Property="Template"><Setter.Value><ControlTemplate?TargetType="{x:Type?CheckBox}"><BulletDecorator?Background="Transparent"><BulletDecorator.Bullet><Border?CornerRadius="{Binding?ElementName=PART_Border,Path=CornerRadius}"Background="{Binding?ElementName=PART_Border,Path=Background}"><Border?x:Name="PART_Border"?Width="16"?Height="16"CornerRadius="3"BorderThickness="1"BorderBrush="{DynamicResource?BaseSolidColorBrush}"Background="{DynamicResource?WhiteSolidColorBrush}"><Grid><Path?x:Name="PART_CheckMark"?SnapsToDevicePixels="False"?VerticalAlignment="Center"?HorizontalAlignment="Center"Data="{StaticResource?PathCheckMark}"RenderTransformOrigin=".5,.5"Stretch="Fill"?Fill="{DynamicResource?WhiteSolidColorBrush}"><Path.RenderTransform><ScaleTransform?ScaleX="0"?ScaleY="0"/></Path.RenderTransform></Path><Rectangle?Width="6"?Height="2"?VerticalAlignment="Center"?HorizontalAlignment="Center"x:Name="PART_InderminateMark"RenderTransformOrigin=".5,.5"Fill="{DynamicResource?PrimaryNormalSolidColorBrush}"><Rectangle.RenderTransform><ScaleTransform?ScaleX="0"/></Rectangle.RenderTransform></Rectangle></Grid></Border></Border></BulletDecorator.Bullet><ContentPresenter?x:Name="PART_ContentPresenter"Focusable="False"HorizontalAlignment="{TemplateBinding?HorizontalContentAlignment}"?Margin="2,0,0,0"?RecognizesAccessKey="True"?SnapsToDevicePixels="{TemplateBinding?SnapsToDevicePixels}"?VerticalAlignment="{TemplateBinding?VerticalContentAlignment}"TextElement.Foreground="{DynamicResource?PrimaryTextSolidColorBrush}"></ContentPresenter><VisualStateManager.VisualStateGroups><VisualStateGroup?x:Name="CheckStates"><VisualState?x:Name="Checked"><Storyboard><DoubleAnimation?Storyboard.TargetName="PART_CheckMark"Storyboard.TargetProperty="(Path.RenderTransform).(ScaleTransform.ScaleX)"?To=".7"?Duration="00:00:.2"EasingFunction="{StaticResource?ExponentialEaseOut}"/><DoubleAnimation?Storyboard.TargetName="PART_CheckMark"Storyboard.TargetProperty="(Path.RenderTransform).(ScaleTransform.ScaleY)"?To=".5"?Duration="00:00:.2"EasingFunction="{StaticResource?ExponentialEaseOut}"/></Storyboard></VisualState><VisualState?x:Name="Unchecked"?/><VisualState?x:Name="Indeterminate"/></VisualStateGroup></VisualStateManager.VisualStateGroups></BulletDecorator><ControlTemplate.Triggers><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><Trigger?Property="IsChecked"?Value="{x:Null}"><Trigger.EnterActions><BeginStoryboard?x:Name="PART_BeginStoryboardIsCheckedNull"><Storyboard><DoubleAnimation?Storyboard.TargetName="PART_InderminateMark"Storyboard.TargetProperty="(Path.RenderTransform).(ScaleTransform.ScaleX)"?To="1"?Duration="00:00:.2"EasingFunction="{StaticResource?ExponentialEaseOut}"/></Storyboard></BeginStoryboard></Trigger.EnterActions><Trigger.ExitActions><RemoveStoryboard?BeginStoryboardName="PART_BeginStoryboardIsCheckedNull"></RemoveStoryboard></Trigger.ExitActions></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></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter></Style></ResourceDictionary>

二、使用?Styles.CheckBox.xaml?代碼如下。

<TextBlock?Text="Checkbox"?FontSize="20"?Margin="0,20,0,0"/><WrapPanel?Margin="0,10"><CheckBox?Content="Option?A"/><CheckBox?Content="Option?B"?Margin="10,0"?IsChecked="True"/><CheckBox?Content="Option?C"?IsChecked="{x:Null}"/><CheckBox?Content="Option?D"?Margin="10,0"?IsEnabled="False"/></WrapPanel>

02


效果預覽

鳴謝素材提供者 -?element

源碼地址如下

Github:https://github.com/WPFDevelopersOrg

Gitee:https://gitee.com/WPFDevelopersOrg

https://gitee.com/WPFDevelopersOrg/WPFDevelopers.Minimal

https://github.com/WPFDevelopersOrg/WPFDevelopers.Minimal

WPF開發者QQ群:?340500857?

Github:https://github.com/WPFDevelopersOrg

出處:https://www.cnblogs.com/yanjinhua

版權:本作品采用「署名-非商業性使用-相同方式共享 4.0 國際」許可協議進行許可。

轉載請著名作者 出處 https://github.com/WPFDevelopersOrg

掃一掃關注我們,

更多知識早知道!

點擊閱讀原文可跳轉至源代碼

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的WPF 基础控件之CheckBox样式的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。