Dreamine.UI.Wpf.Controls
1.0.1
Dreamine.UI.Wpf.Controls 사용자 인터페이스 기능과 구성 요소를 제공합니다.
Toggle main menu visibility
로딩중...
검색중...
일치하는것 없음
DreamineRadioButton.cs
이 파일의 문서화 페이지로 가기
1
using
System.Windows;
2
using
System.Windows.Controls;
3
using
System.Windows.Controls.Primitives;
4
using
System.Windows.Input;
5
6
namespace
Dreamine.UI.Wpf.Controls
7
{
16
public
class
DreamineRadioButton
: RadioButton
17
{
26
static
DreamineRadioButton
()
27
{
28
DefaultStyleKeyProperty.OverrideMetadata(typeof(
DreamineRadioButton
),
29
new
FrameworkPropertyMetadata(typeof(
DreamineRadioButton
)));
30
31
var uri =
new
Uri(
"/Dreamine.UI.Wpf.Themes;component/DreamineRadioButtonStyle.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
new
static
readonly DependencyProperty
CommandProperty
=
56
DependencyProperty.RegisterAttached(
57
"Command"
,
58
typeof(ICommand),
59
typeof(
DreamineRadioButton
),
60
new
PropertyMetadata(
null
,
OnCommandChanged
));
61
70
public
new
static
readonly DependencyProperty
CommandParameterProperty
=
71
DependencyProperty.RegisterAttached(
72
"CommandParameter"
,
73
typeof(
object
),
74
typeof(
DreamineRadioButton
),
75
new
PropertyMetadata(
null
));
76
85
public
static
readonly DependencyProperty
CommandTriggerNameProperty
=
86
DependencyProperty.RegisterAttached(
87
"CommandTriggerName"
,
88
typeof(
string
),
89
typeof(
DreamineRadioButton
),
90
new
PropertyMetadata(
null
));
91
124
public
static
void
SetCommandTriggerName
(DependencyObject obj,
string
value)
125
=> obj.SetValue(
CommandTriggerNameProperty
, value);
126
167
public
static
string
GetCommandTriggerName
(DependencyObject obj)
168
=> (string)obj.GetValue(
CommandTriggerNameProperty
);
169
202
public
static
void
SetCommand
(DependencyObject obj, ICommand value) => obj.SetValue(
CommandProperty
, value);
203
244
public
static
ICommand
GetCommand
(DependencyObject obj) => (ICommand)obj.GetValue(
CommandProperty
);
245
278
public
static
void
SetCommandParameter
(DependencyObject obj,
object
value)
279
=> obj.SetValue(
CommandParameterProperty
, value);
280
313
public
static
object
GetCommandParameter
(DependencyObject obj)
314
=> obj.GetValue(
CommandParameterProperty
);
315
348
private
static
void
OnCommandChanged
(DependencyObject d, DependencyPropertyChangedEventArgs e)
349
{
350
if
(d is UIElement element)
351
{
352
element.AddHandler(UIElement.PreviewMouseUpEvent,
new
MouseButtonEventHandler((s, e) =>
353
{
354
TryExecuteCommand
(d,
"PreviewMouseUp"
, e);
355
}),
true
);
356
357
element.AddHandler(Control.MouseDoubleClickEvent,
new
MouseButtonEventHandler((s, e) =>
358
{
359
TryExecuteCommand
(d,
"MouseDoubleClick"
, e);
360
}),
true
);
361
362
element.AddHandler(UIElement.PreviewKeyDownEvent,
new
KeyEventHandler((s, e) =>
363
{
364
TryExecuteCommand
(d,
"PreviewKeyUp"
, e);
365
}),
true
);
366
367
element.AddHandler(UIElement.TouchUpEvent,
new
EventHandler<TouchEventArgs>((s, e) =>
368
{
369
TryExecuteCommand(d,
"TouchUp"
, e);
370
}));
371
372
element.AddHandler(ButtonBase.ClickEvent,
new
RoutedEventHandler((s, e) =>
373
{
374
TryExecuteCommand
(d,
"Click"
, e);
375
}));
376
}
377
}
378
411
private
static
void
TryExecuteCommand
(DependencyObject d,
string
eventName, RoutedEventArgs eventArgs)
412
{
413
var rawTrigger =
GetCommandTriggerName
(d);
414
if
(
string
.IsNullOrEmpty(rawTrigger))
415
return
;
416
417
var triggerList = rawTrigger.Split(
','
)
418
.Select(x => x.Trim())
419
.Where(x => !
string
.IsNullOrEmpty(x));
420
421
if
(!triggerList.Contains(eventName, StringComparer.OrdinalIgnoreCase))
422
return
;
423
424
var command =
GetCommand
(d);
425
var parameter =
GetCommandParameter
(d) ?? eventArgs;
426
427
if
(command?.CanExecute(parameter) ==
true
)
428
command.Execute(parameter);
429
}
430
}
431
}
Dreamine.UI.Wpf.Controls
Definition
DreamineCheckSelector.xaml.cs:6
Dreamine.UI.Wpf.Controls.DreamineRadioButton.SetCommandTriggerName
static void SetCommandTriggerName(DependencyObject obj, string value)
Definition
DreamineRadioButton.cs:124
Dreamine.UI.Wpf.Controls.DreamineRadioButton.GetCommandParameter
static object GetCommandParameter(DependencyObject obj)
Definition
DreamineRadioButton.cs:313
Dreamine.UI.Wpf.Controls.DreamineRadioButton.CommandTriggerNameProperty
static readonly DependencyProperty CommandTriggerNameProperty
Definition
DreamineRadioButton.cs:85
Dreamine.UI.Wpf.Controls.DreamineRadioButton.GetCommandTriggerName
static string GetCommandTriggerName(DependencyObject obj)
Definition
DreamineRadioButton.cs:167
Dreamine.UI.Wpf.Controls.DreamineRadioButton.CommandProperty
static new readonly DependencyProperty CommandProperty
Definition
DreamineRadioButton.cs:55
Dreamine.UI.Wpf.Controls.DreamineRadioButton.TryExecuteCommand
static void TryExecuteCommand(DependencyObject d, string eventName, RoutedEventArgs eventArgs)
Definition
DreamineRadioButton.cs:411
Dreamine.UI.Wpf.Controls.DreamineRadioButton.CommandParameterProperty
static new readonly DependencyProperty CommandParameterProperty
Definition
DreamineRadioButton.cs:70
Dreamine.UI.Wpf.Controls.DreamineRadioButton.DreamineRadioButton
static DreamineRadioButton()
Definition
DreamineRadioButton.cs:26
Dreamine.UI.Wpf.Controls.DreamineRadioButton.OnCommandChanged
static void OnCommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
Definition
DreamineRadioButton.cs:348
Dreamine.UI.Wpf.Controls.DreamineRadioButton.SetCommand
static void SetCommand(DependencyObject obj, ICommand value)
Definition
DreamineRadioButton.cs:202
Dreamine.UI.Wpf.Controls.DreamineRadioButton.SetCommandParameter
static void SetCommandParameter(DependencyObject obj, object value)
Definition
DreamineRadioButton.cs:278
Dreamine.UI.Wpf.Controls.DreamineRadioButton.GetCommand
static ICommand GetCommand(DependencyObject obj)
Definition
DreamineRadioButton.cs:244
Controls
DreamineRadioButton.cs
다음에 의해 생성됨 :
1.17.0