Dreamine.UI.Maui 1.0.1
Windows(WinUI)의 네이티브 `CheckBox`는 `WidthRequest`로 줄일 수 없는 거대한 최소 너비를 가져서 라벨과의 간격이 벌어지는 문제가 있어, 처음부터 직접 그려서 만들었습니다.
로딩중...
검색중...
일치하는것 없음
DreamineExpander.xaml.cs
이 파일의 문서화 페이지로 가기
1namespace Dreamine.UI.Maui;
2
11public partial class DreamineExpander : ContentView
12{
21 public static readonly BindableProperty HeaderProperty = BindableProperty.Create(
22 nameof(Header), typeof(string), typeof(DreamineExpander), string.Empty,
23 propertyChanged: (b, _, n) => ((DreamineExpander)b).HeaderLabel.Text = (string)n);
24
33 public static readonly BindableProperty IsExpandedProperty = BindableProperty.Create(
34 nameof(IsExpanded), typeof(bool), typeof(DreamineExpander), true,
35 defaultBindingMode: BindingMode.TwoWay,
36 propertyChanged: (b, _, n) => ((DreamineExpander)b).ApplyExpandedState());
37
46 public static readonly BindableProperty ExpanderContentProperty = BindableProperty.Create(
47 nameof(ExpanderContent), typeof(View), typeof(DreamineExpander), null,
48 propertyChanged: (b, _, n) => ((DreamineExpander)b).ContentHost.Content = (View?)n);
49
58 public string Header
59 {
60 get => (string)GetValue(HeaderProperty);
61 set => SetValue(HeaderProperty, value);
62 }
63
72 public bool IsExpanded
73 {
74 get => (bool)GetValue(IsExpandedProperty);
75 set => SetValue(IsExpandedProperty, value);
76 }
77
86 public View? ExpanderContent
87 {
88 get => (View?)GetValue(ExpanderContentProperty);
89 set => SetValue(ExpanderContentProperty, value);
90 }
91
100 public event EventHandler? ExpandedChanged;
101
111 {
112 InitializeComponent();
114 }
115
140 private void OnHeaderTapped(object? sender, TappedEventArgs e)
141 {
143 ExpandedChanged?.Invoke(this, EventArgs.Empty);
144 }
145
154 private void ApplyExpandedState()
155 {
156 ContentHost.IsVisible = IsExpanded;
157 ArrowLabel.Text = IsExpanded ? "▼" : "▶";
158 }
159}
static readonly BindableProperty IsExpandedProperty
static readonly BindableProperty ExpanderContentProperty
static readonly BindableProperty HeaderProperty
void OnHeaderTapped(object? sender, TappedEventArgs e)