Dreamine.UI.Maui 1.0.1
Windows(WinUI)의 네이티브 `CheckBox`는 `WidthRequest`로 줄일 수 없는 거대한 최소 너비를 가져서 라벨과의 간격이 벌어지는 문제가 있어, 처음부터 직접 그려서 만들었습니다.
로딩중...
검색중...
일치하는것 없음
DreamineCheckBox.xaml.cs
이 파일의 문서화 페이지로 가기
2
19public partial class DreamineCheckBox : ContentView
20{
29 public static readonly BindableProperty IsCheckedProperty = BindableProperty.Create(
30 nameof(IsChecked), typeof(bool), typeof(DreamineCheckBox), false,
31 defaultBindingMode: BindingMode.TwoWay,
32 propertyChanged: (b, _, n) => ((DreamineCheckBox)b).ApplyState());
33
42 public static readonly BindableProperty TextProperty = BindableProperty.Create(
43 nameof(Text), typeof(string), typeof(DreamineCheckBox), string.Empty,
44 propertyChanged: (b, _, n) => ((DreamineCheckBox)b).TextLabel.Text = (string)n);
45
54 public bool IsChecked
55 {
56 get => (bool)GetValue(IsCheckedProperty);
57 set => SetValue(IsCheckedProperty, value);
58 }
59
68 public string Text
69 {
70 get => (string)GetValue(TextProperty);
71 set => SetValue(TextProperty, value);
72 }
73
82 public event EventHandler<bool>? CheckedChanged;
83
93 {
94 InitializeComponent();
95 ApplyState();
96 }
97
122 private void OnTapped(object? sender, TappedEventArgs e)
123 {
125 CheckedChanged?.Invoke(this, IsChecked);
126 }
127
136 private void ApplyState()
137 {
138 CheckMark.IsVisible = IsChecked;
139 Box.BackgroundColor = IsChecked ? Color.FromArgb("#0d6efd") : Colors.Transparent;
140 Box.Stroke = IsChecked ? Color.FromArgb("#0d6efd") : Color.FromArgb("#7A8AA0");
141 }
142}
static readonly BindableProperty TextProperty
void OnTapped(object? sender, TappedEventArgs e)
static readonly BindableProperty IsCheckedProperty