8 Answers, 1 is accepted
The RadMaskedInputControls are designed to work with their Value property. Value is of type string in TextInput, double? in NumericInput, decimal? in CurrencyInput and DateTime? in DateTimeInput. The Text property is of type string and it returns actually the string you see when focus is lost - Text is result of the combination of Value, Mask, PlaceHolder, TextMode. You can consider Text as only a getter property , setting it is possible but won't do nothing - won't actually change the Value.
Could you please elaborate more on your particular scenario - what do you need to save as a value and what do you need to be displayed as a string? This way we would be better able to help you. Probably this requirement could be achieved with combination no-mask, FormatString or something similar. We would be glad to help you further.
Regards,
Petar Mladenov
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
I'm using it to store a value in a phone number field. There's a corresponding country code used in a trigger and if the country code is 1 then I apply a mask in order to enforce a specific format. However, it's important that the formatting characters are stored for readability. That is, I want to store and use (678) 555-1234 not 6785551234.
Everything except the binding to the Text property works.
Let's suppose you have the string "(678)555-1234" in the database. Generally you have two options:
- Use RadMaskedTextInput with Mask="" (no-mask). Then bind the Value two-way to the db string.
The negative effect of this approach is that you have to type the brackets and the minus symbol manually.
- Use RadMaskedNumericInput / RadMaskedTextInput with Mask = "(d3)d3-d3". Bind the Value to the dbString one way with converter:
Value = {Binding dbString, Mode=TwoWay, Converter={StaticResource converter }}
We hope this will help you proceed further.
Regards,
Petar Mladenov
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Thank you. I used a converter in conjunction with a DataTrigger (since I didn't want to use the mask if the country code wasn't 1). It's behaving the way I want now.
Here's a trimmed down version of my XAML in case this is useful for anyone else.
<Style x:Key="PhoneFormatStyle" TargetType="{x:Type telerik:RadMaskedTextInput">
<Setter Property="Value" Value={Binding ...}" />
<Setter Property="Mask Value="" />
...
<Style.Triggers>
<DataTrigger Binding={Binding ...} Value="1">
<Setter Property="Value" Value="{Binding ..., Converter={StaticResource PhoneFormatConverter}}" />
<Setter Property="Mask" Value="(d3) d3-d4" />
</DataTrigger>
</Style.Triggers>
</Style>
In order to log a feature request in our system, or to help you with a possible solution, could you please elaborate a bit more on your particular scenarios ? You can send us your top 3 popular scenarios - what masks do you use in them, what formatting and conversion do you need and what kind of values do you save / use ? Thank you in advance for your cooperation.
Regards,
Petar Mladenov
Telerik
DevCraft Q1'14 is here! Join the free online conference to see how this release solves your top-5 .NET challenges. Reserve your seat now!
Simply put I want the ability to databind to the Text property, so that I can get the formatting characters included.
One particular scenario is that the phone numbers are going to have different formats in different locations. However, you may not want to store just a set of numbers and have to replicate the formatting logic to other systems (especially reporting) that use the data. The same thing can apply to other areas like postal codes.
You can vote for this related feature request and this way you will increase its development priority.
Regards,
Petar Mladenov
Telerik
DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.