跳到主要内容

github/tai

公开

Tai · Windows 软件与网站使用时长统计。上游 Planshit/Tai 的源码镜像,非灵栈原创;MIT 许可。来源:https://github.com/Planshit/Tai 。本次为手动同步,暂不提供安装包。

浏览文件

Option.cs

53 行 · 1.7 KB历史下载
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6using System.Windows;
7using System.Windows.Controls;
8
9namespace UI.Controls.Select
10{
11 public class Option : Control
12 {
13 public bool IsShowIcon
14 {
15 get { return (bool)GetValue(IsShowIconProperty); }
16 set { SetValue(IsShowIconProperty, value); }
17 }
18 public static readonly DependencyProperty IsShowIconProperty =
19 DependencyProperty.Register("IsShowIcon",
20 typeof(bool),
21 typeof(Option), new PropertyMetadata(true));
22 public bool IsChecked
23 {
24 get { return (bool)GetValue(IsCheckedProperty); }
25 set { SetValue(IsCheckedProperty, value); }
26 }
27 public static readonly DependencyProperty IsCheckedProperty =
28 DependencyProperty.Register("IsChecked",
29 typeof(bool),
30 typeof(Option), new PropertyMetadata(false));
31
32 public SelectItemModel Value
33 {
34 get { return (SelectItemModel)GetValue(ValueProperty); }
35 set { SetValue(ValueProperty, value); }
36 }
37 public static readonly DependencyProperty ValueProperty =
38 DependencyProperty.Register("Value",
39 typeof(SelectItemModel),
40 typeof(Option));
41 public Option()
42 {
43 DefaultStyleKey = typeof(Option);
44
45 MouseLeftButtonUp += Option_MouseLeftButtonUp;
46 }
47
48 private void Option_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
49 {
50 IsChecked = !IsChecked;
51 }
52 }
53}