xaml代码:
| 代码如下 | 复制代码 |
|
xmlns="http://schemas.*m*icros*oft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.*mic*ro*soft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxm*lf*ormat*s.org/markup-compatibility/2006" xmlns:d="http://schemas.mi**cros*oft.com/expression/blend/2008" mc:Ignorable="d" d:DesignHeight="24" d:DesignWidth="60"> Background="Transparent" Width="60" Height="24"> BorderThickness="1" Margin="4,2" Padding="0" CornerRadius="8" Background="#2ecc71"> Fill="#e74c3c" RadiusX="8" RadiusY="8" Visibility="Collapsed"/> BorderBrush="#aaaaaa" BorderThickness="1" HorizontalAlignment="Left" CornerRadius="15" Width="24" Height="24"> Fill="#FFF1F1F1" StrokeThickness="0" Width="22" RadiusX="15" RadiusY="15"/> |
|
Cs代码:主要是重构一https://www.111cn.net些事件和返回参数:
| 代码如下 | 复制代码 |
| using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace Kaitone.DetectiveHelper.UI.Controls { /// /// ToggleSwitchButton.xaml 的交互逻辑 /// public partial class ToggleSwitchButton : UserControl { public static readonly DependencyProperty IsCheckedProperty = DependencyProperty.Register("IsChecked", typeof(bool), typeof(ToggleSwitchButton), new PropertyMetadata(default(bool), OnIsCheckedChanged)); public event RoutedEventHandler Checked; public event RoutedEventHandler UnChecked; public bool IsChecked { get { return (bool)GetValue(IsCheckedProperty); } set { SetValue(IsCheckedProperty, value); } } public ToggleSwitchButton() { InitializeComponent(); } private static void OnIsCheckedChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { (obj as ToggleSwitchButton).OnIsCheckedChanged(args); } private void OnIsCheckedChanged(DependencyPropertyChangedEventArgs args) { fillRectangle.Visibility = IsChecked ? Visibility.Visible : Visibility.Collapsed; slideBorder.HorizontalAlignment = IsChecked ? HorizontalAlignment.Right : HorizontalAlignment.Left; if (IsChecked && Checked != null) { Checked(this, new RoutedEventArgs()); } if (!IsChecked && UnChecked != null) { UnChecked(this, new RoutedEventArgs()); } } protected override void OnMouseLeftButtonUp(MouseButtonEventArgs args) { args.Handled = true; IsChecked ^= true; base.OnMouseLeftButtonUp(args); } } } |
|
Tplink企业版路由器WiFi名称的默认设置介绍(Tplink企业版路由器WiFi名称的默认设置是什么)
Tplink路由器灯常亮无法上网的原因分析(如何解决Tplink路由器灯常亮无法上网的问题)
Tplink千兆企业级路由器自动重启的作用和优势介绍(如何设置Tplink千兆企业级路由器自动重启功能)
一根天线的tplink路由器有哪些(一根天线的Tplink路由器的特点和优势介绍)
tplink路由器外网访问不了nas(Tplink路由器外网访问NAS的原因分析)
Tplink无法搜到路由器的原因分析(如何解决Tplink无法搜到路由器的问题)