2009/12/12作成
×
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
[WPF] KeyDownをプログラムから呼び出す
writer:オレ 2012-12-26(Wed) .NET
○WPFプロジェクト内から呼び出す場合
Dim key As Key = Key.Insert
Dim target As UIElement = Keyboard.FocusedElement
Dim routedEvent As RoutedEvent = Keyboard.KeyDownEvent
Dim e As KeyEventArgs = New KeyEventArgs(
Keyboard.PrimaryDevice,
PresentationSource.FromVisual(target),
0,
key)
e.RoutedEvent = routedEvent
Grid1.RaiseEvent(e)
○単体テストプロジェクト内から呼び出す場合
Dim params As HwndSourceParameters = New HwndSourceParameters()
Dim source As HwndSource = New HwndSource(params)
Dim k As Key = Key.A
Dim e As KeyEventArgs = New KeyEventArgs(Keyboard.PrimaryDevice, source, 0, k)
e.RoutedEvent = routedEvent
Grid1.RaiseEvent(e)
Dim key As Key = Key.Insert
Dim target As UIElement = Keyboard.FocusedElement
Dim routedEvent As RoutedEvent = Keyboard.KeyDownEvent
Dim e As KeyEventArgs = New KeyEventArgs(
Keyboard.PrimaryDevice,
PresentationSource.FromVisual(target),
0,
key)
e.RoutedEvent = routedEvent
Grid1.RaiseEvent(e)
○単体テストプロジェクト内から呼び出す場合
Dim params As HwndSourceParameters = New HwndSourceParameters()
Dim source As HwndSource = New HwndSource(params)
Dim k As Key = Key.A
Dim e As KeyEventArgs = New KeyEventArgs(Keyboard.PrimaryDevice, source, 0, k)
e.RoutedEvent = routedEvent
Grid1.RaiseEvent(e)
PR
この記事にコメントする
この記事へのコメント
新着記事
2013 - 06 - 27
2013 - 06 - 27
2013 - 06 - 19
2013 - 01 - 11
2013 - 01 - 11
カテゴリー
アーカイブ
検索
新着コメント
ブックマーク