I have the following code. The window has a textbox and a checkbox. If I have focus on the anything other than checkbox and type something like 123-456 then for each character PreviewKeyDown and PreviewTextInput are firing.
But if I have the focus to checkbox and then type 123-456 then the PreviewKeyDown is fired for all the characters whereas PreviewTextInput fires only for 123456 and doesn't fire for '-'. The hyphen is being handled by the checkbox and not getting passed to PreviewTextInput. Is there a way to get the hyphen to PreviewTextInput?
public Window1()
{
InitializeComponent();
TextCompositionManager.AddTextInputHandler(this, new TextCompositionEventHandler(Window_PreviewTextInput));
}
private void Window_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
}
private void Window_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
}