私は次のコードを持っています。ウィンドウにはテキストボックスとチェックボックスがあります。チェックボックス以外のものに焦点を合わせて、123-456のようなものを入力した場合は、キャラクターごとPreviewKeyDown
にPreviewTextInput
発砲します。
しかし、チェックボックスにフォーカスがあり、123-456と入力するとPreviewKeyDown
、すべての文字に対してが起動されますがPreviewTextInput
、123456に対してのみ起動され、。に対しては起動されません-。ハイフンはチェックボックスによって処理されており、に渡されていませんPreviewTextInput
。ハイフンを取得する方法はあります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)
{
}