Dreamine.UI.Wpf.Controls 1.0.1
Dreamine.UI.Wpf.Controls 사용자 인터페이스 기능과 구성 요소를 제공합니다.
로딩중...
검색중...
일치하는것 없음
DreamineExpander.cs
이 파일의 문서화 페이지로 가기
1using System.Windows;
2using System.Windows.Controls;
3using System.Windows.Input;
4using System.Windows.Media;
5
7{
16 public class DreamineExpander : HeaderedContentControl
17 {
27 {
28 DefaultStyleKeyProperty.OverrideMetadata(typeof(DreamineExpander),
29 new FrameworkPropertyMetadata(typeof(DreamineExpander)));
30
31 var uri = new Uri("/Dreamine.UI.Wpf.Themes;component/DreamineExpanderStyle.xaml", UriKind.RelativeOrAbsolute);
32
33 if (Application.Current != null)
34 {
35 bool alreadyAdded = Application.Current.Resources.MergedDictionaries
36 .OfType<ResourceDictionary>()
37 .Any(x => x.Source != null && x.Source.Equals(uri));
38
39 if (!alreadyAdded)
40 {
41 var dict = new ResourceDictionary { Source = uri };
42 Application.Current.Resources.MergedDictionaries.Add(dict);
43 }
44 }
45 }
46
55 public bool IsExpanded
56 {
57 get => (bool)GetValue(IsExpandedProperty);
58 set => SetValue(IsExpandedProperty, value);
59 }
60
69 public static readonly DependencyProperty IsExpandedProperty =
70 DependencyProperty.Register(nameof(IsExpanded), typeof(bool), typeof(DreamineExpander),
71 new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsExpandedChanged));
72
105 private static void OnIsExpandedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
106 {
107 if (d is DreamineExpander expander)
108 {
109 if (expander.ExpandChangedCommand?.CanExecute(null) == true)
110 {
111 expander.ExpandChangedCommand.Execute(null);
112 }
113 else
114 {
115 if ((bool)expander.ShowExpandIcon == false && (bool)e.NewValue == false)
116 expander.IsExpanded = true;
117 }
118 }
119 }
120
129 public ICommand ExpandChangedCommand
130 {
131 get => (ICommand)GetValue(ExpandChangedCommandProperty);
132 set => SetValue(ExpandChangedCommandProperty, value);
133 }
134
143 public static readonly DependencyProperty ExpandChangedCommandProperty =
144 DependencyProperty.Register(nameof(ExpandChangedCommand), typeof(ICommand), typeof(DreamineExpander));
145
155 {
156 get => (bool)GetValue(UseExpandAnimationProperty);
157 set => SetValue(UseExpandAnimationProperty, value);
158 }
159
168 public static readonly DependencyProperty UseExpandAnimationProperty =
169 DependencyProperty.Register(nameof(UseExpandAnimation), typeof(bool), typeof(DreamineExpander), new PropertyMetadata(true));
170
180 {
182 set => SetValue(ArrowPlacementProperty, value);
183 }
184
193 public static readonly DependencyProperty ArrowPlacementProperty =
194 DependencyProperty.Register(nameof(ArrowPlacement), typeof(ExpanderArrowPlacement), typeof(DreamineExpander),
195 new PropertyMetadata(ExpanderArrowPlacement.Left));
196
205 public double HeaderFontSize
206 {
207 get { return (double)GetValue(HeaderFontSizeProperty); }
208 set { SetValue(HeaderFontSizeProperty, value); }
209 }
210
219 public static readonly DependencyProperty HeaderFontSizeProperty =
220 DependencyProperty.Register("HeaderFontSize", typeof(double), typeof(DreamineExpander), new PropertyMetadata(SystemFonts.MessageFontSize));
221
230 public FontWeight HeaderFontWeight
231 {
232 get { return (FontWeight)GetValue(HeaderFontWeightProperty); }
233 set { SetValue(HeaderFontWeightProperty, value); }
234 }
235
244 public static readonly DependencyProperty HeaderFontWeightProperty =
245 DependencyProperty.Register("HeaderFontWeight", typeof(FontWeight), typeof(DreamineExpander), new PropertyMetadata(FontWeights.Normal));
246
255 public Brush HeaderForeground
256 {
257 get { return (Brush)GetValue(HeaderForegroundProperty); }
258 set { SetValue(HeaderForegroundProperty, value); }
259 }
260
269 public static readonly DependencyProperty HeaderForegroundProperty =
270 DependencyProperty.Register("HeaderForeground", typeof(Brush), typeof(DreamineExpander), new PropertyMetadata(SystemColors.ControlTextBrush));
271
280 public bool ShowExpandIcon
281 {
282 get => (bool)GetValue(ShowExpandIconProperty);
283 set => SetValue(ShowExpandIconProperty, value);
284 }
285
294 public static readonly DependencyProperty ShowExpandIconProperty =
295 DependencyProperty.Register(nameof(ShowExpandIcon), typeof(bool), typeof(DreamineExpander),
296 new PropertyMetadata(true));
297 }
298
308 {
318
328 }
329}
static readonly DependencyProperty ExpandChangedCommandProperty
static void OnIsExpandedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
static readonly DependencyProperty UseExpandAnimationProperty
static readonly DependencyProperty IsExpandedProperty
static readonly DependencyProperty ArrowPlacementProperty
static readonly DependencyProperty HeaderFontWeightProperty
static readonly DependencyProperty HeaderFontSizeProperty
static readonly DependencyProperty ShowExpandIconProperty
static readonly DependencyProperty HeaderForegroundProperty