I have a MaskedTextBox with such mask ([\-\+])?0x([A-Fa-f0-9]*).
It is a mask for relative offset i.e. +0x16 mean currentOffset+=0x16 and i want it to support normal offsets i.e 0x42
I want to disable posibility of deletion 0x part of mask for this purposies I've added such TextChanging handler
private void OnTextChanging(object sender, StringPropertyChangingRoutedEventArgs e)
{
e.Cancel = !(GoToModel.DistanceRegex.IsMatch(e.NewValue));
}
where GoToModel.DistanceRegex is System.Text.RegularExpressions.Regex.
The problem:
0x is enterd by default. When user prepend + it becomes imposible to delete it because e.NewValue is empty string. I expect it to be "0x".
Is it a bug? Is there any workaround?
[Modified 10 years ago]