I'm using a key_up event on my window to append the data typed to a string builder.
<Grid x:Name="grdMain" KeyUp="grdMain_KeyUp">
<Grid.RowDefinitions>...
private StringBuilder buffer = new StringBuilder();
private void Window_KeyUp(object sender, KeyEventArgs e)
{
if (e.Key != Key.Enter)
{
buffer.Append(e.Key);
}
the thing is that the data applied to the buffer is "NumPad4" instead of "4" and "D3" instead of "3"... am i missing something? is there a way to append the data as if it was typed into a textbox? i know that i can convert the data my self but it seems weird that there is no built in way to do so.
You could use TextCompositionManager.TextInput Attached Event.
<Grid x:Name="grdMain"
TextCompositionManager.TextInput="grid_TextInput">
In TextCompositionEventArgs you will find what you want.
private void grid_TextInput(object sender, TextCompositionEventArgs e)
{
MessageBox.Show(e.Text);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With