tags:

views:

192

answers:

3

I need a WPF Textbox that displays a phone number as "(555) 555-5555" but has a value of "5555555555".

All of the examples I'm seeing have the ability to mask the control on the UI but that affects the bound property of my view model so that the property value has the extraneous ()- characters.

A: 

I am thinking that you will probably have to roll-your-own. It shouldn't be too difficult, subclass and override to obtain the results you are looking for.

Muad'Dib
+1  A: 

How about an IValueConverter?

Peter
Ya know, I don't know how many times I had thought of IValueConverter but I kept going back to the fact that with *just* a value converter, the user wouldn't be presented with the mask while typing in the value through the UI. Then as you recommended it, it hit me. Use both the mask control *and* a value converter.
Rick Kierner
A: 

You can check out the link below:

http://www.viblend.com/products/net/wpf/controls/free-wpf-controls.aspx

Their free wpf editors include masked textbox, date/time picker, date/time editor, percentage editor, currency editor and so on.

Jane