Dreamine.MVVM.Behaviors
1.0.4
Dreamine.MVVM.Behaviors 산업 자동화 및 I/O 기능을 제공합니다.
Toggle main menu visibility
로딩중...
검색중...
일치하는것 없음
EnterKeyCommandBehavior.cs
이 파일의 문서화 페이지로 가기
1
using
System.Windows;
2
using
System.Windows.Controls;
3
using
System.Windows.Input;
4
using
Dreamine.MVVM.Behaviors.Core.Base;
5
6
namespace
Dreamine.MVVM.Behaviors.MVVM
7
{
16
public
class
EnterKeyCommandBehavior
: Behavior<UIElement>
17
{
26
public
static
readonly DependencyProperty
CommandProperty
=
27
DependencyProperty.RegisterAttached(
28
"Command"
,
29
typeof(ICommand),
30
typeof(
EnterKeyCommandBehavior
),
31
new
PropertyMetadata(
null
,
OnCommandChanged
));
32
57
public
static
ICommand?
GetCommand
(DependencyObject obj)
58
{
59
return
(ICommand?)obj.GetValue(
CommandProperty
);
60
}
61
86
public
static
void
SetCommand
(DependencyObject obj, ICommand? value)
87
{
88
obj.SetValue(
CommandProperty
, value);
89
}
90
115
private
static
void
OnCommandChanged
(DependencyObject d, DependencyPropertyChangedEventArgs e)
116
{
117
if
(d is UIElement element)
118
{
119
element.KeyDown -=
OnKeyDown
;
120
element.KeyDown +=
OnKeyDown
;
121
}
122
}
123
148
private
static
void
OnKeyDown
(
object
sender, KeyEventArgs e)
149
{
150
if
(e.Key == Key.Enter && sender is DependencyObject obj)
151
{
152
ICommand? command =
GetCommand
(obj);
153
if
(command?.CanExecute(
null
) ==
true
)
154
{
155
command.Execute(
null
);
156
e.Handled =
true
;
157
}
158
}
159
}
160
}
161
}
Dreamine.MVVM.Behaviors.MVVM
Definition
EnterKeyCommandBehavior.cs:7
Dreamine.MVVM.Behaviors.MVVM.EnterKeyCommandBehavior
Definition
EnterKeyCommandBehavior.cs:17
Dreamine.MVVM.Behaviors.MVVM.EnterKeyCommandBehavior.OnCommandChanged
static void OnCommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
Definition
EnterKeyCommandBehavior.cs:115
Dreamine.MVVM.Behaviors.MVVM.EnterKeyCommandBehavior.OnKeyDown
static void OnKeyDown(object sender, KeyEventArgs e)
Definition
EnterKeyCommandBehavior.cs:148
Dreamine.MVVM.Behaviors.MVVM.EnterKeyCommandBehavior.GetCommand
static ? ICommand GetCommand(DependencyObject obj)
Definition
EnterKeyCommandBehavior.cs:57
Dreamine.MVVM.Behaviors.MVVM.EnterKeyCommandBehavior.CommandProperty
static readonly DependencyProperty CommandProperty
Definition
EnterKeyCommandBehavior.cs:26
Dreamine.MVVM.Behaviors.MVVM.EnterKeyCommandBehavior.SetCommand
static void SetCommand(DependencyObject obj, ICommand? value)
Definition
EnterKeyCommandBehavior.cs:86
MVVM
EnterKeyCommandBehavior.cs
다음에 의해 생성됨 :
1.17.0