0

I found the Key class for determining key input in a textbox but it seems to be just for wpf. How do I use it in Silverlight?

https://msdn.microsoft.com/en-us/library/aa274297(v=vs.60).aspx

Martin
  • 5,714
  • 2
  • 21
  • 41
xarzu
  • 8,657
  • 40
  • 108
  • 160

1 Answers1

0

I'm only aware of the Key enum in Silverlight; it contains the keys available on a keyboard so if you receive keyboard input you can determine which key was pressed and react accordingly. An examle:

public DropDownButton()
{
    DefaultStyleKey = typeof( DropDownButton );
    KeyDown += HandleEscapeKey;
}

private void HandleEscapeKey( object sender, KeyEventArgs e )
{
    if (e.Key == Key.Escape && IsDropDownOpen)
    {
        CloseDropDown();
        e.Handled = true;
    }
}
Martin
  • 5,714
  • 2
  • 21
  • 41