Problem

MaskedTextBox writes Prompt character to bound property

Posted 10 months ago by Avatar Bjørnar Sundsbø - Norway

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 10 months ago by Actipro Software Support - Cleveland, OH, USA

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 10 months ago by Bjørnar Sundsbø - Norway

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 10 months ago by Actipro Software Support - Cleveland, OH, USA

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
Information The latest build of this product (2018.1 build 0672) was released 2 months ago, which was after the last post in this thread.

Add a Comment

Please log in to a validated account to post comments.