When the user adds a ;, I want to add ; + Environment.NewLine in the TextBox.
I find this solution :
private void TextBox_OnPreviewTextInput(object sender, TextCompositionEventArgs e)
{
if (e.Text == ";")
{
e.Handled = true;
TextCompositionManager.StartComposition(
new TextComposition(InputManager.Current,
(IInputElement)sender,
";" + Environment.NewLine)
);
}
}
But after this, the undo don't work.
Can you explain me how control the user input and keep the undo stack?