MaskedTextBox writes Prompt character to bound property

Editors for WPF Forum

Posted 6 years ago by Bjørnar Sundsbø - Norway
Version: 17.2.0662
Platform: .NET 4.6
Environment: Windows 10 (64-bit)
Avatar

While migrating our product to use the latest version of MaskedTextBox, I have discovered a very inconvenient issue. Binding the Text property of the masked textbox to a property in my viewmodel, I've ended up with a database containing the prompt characters in some situations. If I set PromptCharacter="", I end up with funny looking squares instead.  

Using the Masked TextBox samle in the Sample Browser, I can sometimes reproduce the issue if I create a property in the codebehind to which I bind, and display the value in a TextBlock below the checkbox in the samle.

When setting PromptVisibility to never, I sometimes get the problem where I have to manually input the - to be able to continue typing. Where in PromptVisibility="FocusedOnly", I don't have to input the dash, but just keep typing numbers, but with Never, I do.


Bjørnar Sundsbø

Comments (3)

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Yes to keep things simple, the MaskedTextBox directly inherits TextBox so the Text property will have prompt characters inserted into it at certain points.  I see how this could be a problem for data binding though.  

What would you suggest as an improvement to help?  Since we inherit TextBox directly, we have to use the Text property to include prompt characters when appropriate.  We could possbly add another property that would only indicate text that matches the pattern and excludes anything after an invalid point, including prompt characters.  Then you could bind to that.  Would that work for your needs?  Any suggestions for a property name?


Actipro Software Support

Posted 6 years ago by Bjørnar Sundsbø - Norway
Avatar

TextBoundValue? That way it will show up in intellisense close to the Text property. Based on your API, it appears you are better at coming up with names than I am, and that was just at the top of my head.


Bjørnar Sundsbø

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

We are going to add it as a MatchedText property for the next build.  If you'd like to try a preview build to verify it works as expected, please write our support address and reference this thread.


Actipro Software Support

The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.