效果如下:
分别有四种用法:
第一种 文字在右边第二种 文字在中间第三种 文字无第四种 一组单选类型实现思路看代码吧,还不够很完美...一、引用方法:
<StackPanelGrid.Row="2"Margin="0,50,0,0"Orientation="Horizontal"><YOI:USwitchButtonWidth="70"Height="30"Margin="10"ActiveBackground="{DynamicResource PrimaryBlueColor}"ActiveForeground="{DynamicResource TextSecundaryColor}"ContentFalse="关闭"ContentTrue="开启"Cursor="Hand"FontSize="14"InactiveBackground="{DynamicResource TextWhiteColor}"SwitchBorderRadius="15"SwitchContentTemplate="Right" /><YOI:USwitchButtonWidth="80"Height="30"Margin="50,10,10,10"ActiveBackground="{DynamicResource PrimaryBlueColor}"ActiveForeground="{DynamicResource TextWhiteColor}"ContentFalse="关闭"ContentTrue="开启"FontSize="14"Foreground="{DynamicResource TextSecundaryColor}"InactiveBackground="{DynamicResource TextWhiteColor}"SwitchBorderRadius="15"SwitchContentTemplate="Middle" /><YOI:USwitchButtonWidth="70"Height="30"Margin="10"ActiveBackground="{DynamicResource PrimaryBlueColor}"ActiveForeground="{DynamicResource PrimaryGreen}"FontSize="14"Foreground="{DynamicResource TextSecundaryColor}"InactiveBackground="{DynamicResource TextWhiteColor}"SwitchBorderRadius="15" /><StackPanelGrid.Row="2"Margin="0,50,0,0"Orientation="Vertical"><YOI:USwitchButtonWidth="70"Height="30"Margin="10"ActiveBackground="{DynamicResource PrimaryBlueColor}"ActiveForeground="{DynamicResource PrimaryGreen}"FontSize="14"Foreground="{DynamicResource TextSecundaryColor}"InactiveBackground="{DynamicResource TextWhiteColor}"SwitchBorderRadius="15"SwitchType="1" /><YOI:USwitchButtonWidth="70"Height="30"Margin="10"ActiveBackground="{DynamicResource PrimaryBlueColor}"ActiveForeground="{DynamicResource PrimaryGreen}"FontSize="14"Foreground="{DynamicResource TextSecundaryColor}"InactiveBackground="{DynamicResource TextWhiteColor}"SwitchBorderRadius="15"SwitchType="1" /></StackPanel>
二、语雀笔记:
/docs/share/a26bfbb5-5c40-4d4b-9daa-06b53da041b0?# 《WPF 自定义开关按钮实现》