星期一, 4月 09, 2007

How to simulation a KeyEventArgs



這裡有一篇在解怎麼用Enter作Focus Navigation



Sheva's TechSpace: Focus Navigation Using Enter Key





剛好解答了我們之前一直找不到怎麼用寫程式的方法Simulation一個keyEvent



解答如下



private void documentRoot_KeyDown(Object sender, KeyEventArgs e)

{

if (e.Key == Key.Return)

{

e.Handled = true;

KeyEventArgs args = new KeyEventArgs(

Keyboard
.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, Key.Tab);

args.RoutedEvent = Keyboard.KeyDownEvent;

InputManager.Current.ProcessInput(args);

//^^^^^^^^^^^^^^^^^^^^^^^^^^原來可以這樣用哦........

}

}








powered by performancing firefox

沒有留言: