I test you code and the app crashed with the error:The error code is 0x80131623. This error may be a bug in the CLR or in the unsafe..... The reason for this error is that a large number of TextBox_TextChanged events were triggered which cause memory issue. You can try the below code and input as you did in the question said.
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
//add a breakpoint here.
}
You will meet the same error, so you need to be careful to use TextBox_TextChanged event. If you want to do limit the TextBox for typing, you can use a DependencyProperty as the backing store for Input Limit. Looking like this:
public static readonly DependencyProperty InputLimitProperty =
DependencyProperty.RegisterAttached("InputLimit", typeof(bool), typeof(TextBoxExtension), new PropertyMetadata(false, InputLimitChanged));