<
Telerik:RadMaskedTextInput
Mask
=
"##--a2"
TextMode
=
"PlainText"
Value
=
"{Binding Value, Mode=TwoWay}"
Text
=
"{Binding Text, Mode=TwoWay}"
/>
Whenever I change the "Value" in my view model, the "Text" gets updated. But what I need as well is the other way round which I think is a pretty common scenario:
Client and server exchange only well formatted strings (e.g. "11--xx"). RadMaskedTextInput is used on client side to ensure the user input matches this format. Now, when I receive a correctly formatted string (e.g. "11--xx") from the server I just want to apply it to the RadMaskedTextInput. If I use Value="11--xx" the result would be "11----" because each character is treated as real input character and not as mask symbol. If I use Text="11--xx" the visible result on the RadMaskedTextInput would indeed be "11--xx" but as soon as it gets the focus, the real "Value" is displayed/edited which is still not updated.
Is there any chance that this will be supported by RadMaskedTextInput in the next release?
If not, what's the best way to solve this pretty common problem?
Cheers,
Stephan
8 Answers, 1 is accepted
The Text property is not designed to be used as a setter, rather than retrieving the fully formatted text. In your scenario, you would have to pass a value in the format ##xx so that it will be displayed as ##--xx.
Greetings,
Alex Fidanov
the Telerik team
is this something that is planned for support ?
The Text property gets the value displayed in the control when it isn't focused. The value of this property depends on the TextMode enumeration, that exposed the following values:
- MaskedText - if a RadMaskedInput control's TextMode property is set to MaskedText, its Text value represents the formatted Value including the placeholder characters.
- PlainText- if a RadMaskedInput control's TextMode property is set to PlainText, its Text value will hold the formatted Value but without the placeholder characters.
Regards,
Tina Stancheva
the Telerik team
thank you for your reply. Yes, we know why it doesn't work at the moment and we know what we have to do to make it work. However, since we think this is a pretty common scenario (see above), the question is: Will Telerik make it ever work out of the box?
Regards,
Stephan
Thank you for getting back to us. I escalated your request to the respective developers and we decided to add a feature request for this. We will do our best to implement such a feature as soon as possible and in the meantime you can track its progress in our PITS.
Regards,
Tina Stancheva
the Telerik team
I am trying to bind to a RadMaskedTextInput Value property as shown below, from the a textblock text property, but the binding does not work. Can you tell me what I am doing wrong.
<telerik:RadMaskedTextInput
Style="{StaticResource RadMaskedTextInputKey}"
TextBoxStyle="{StaticResource textboxTrimming}"
MaxHeight="40"
Mask=""
Value="abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvw">
<ToolTipService.ToolTip>
<TextBlock
Text="{Binding RelativeSource ={RelativeSource Mode=FindAncestor,AncestorType={x:Type telerik:RadMaskedTextInput}}, Path=Value}">
</TextBlock> </ToolTipService.ToolTip>
</telerik:RadMaskedTextInput>
Such binding cannot work because the ToolTip resides in separate visual tree. This can be implemented in two ways:
Solution 1)
<
telerik:RadMaskedTextInput
x:Name
=
"maskedInput"
Style="{StaticResource RadMaskedTextInputKey}"
TextBoxStyle="{StaticResource textboxTrimming}"
MaxHeight="40"
Mask=""
Value="abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvw"
>
<ToolTipService.ToolTip>
<ToolTip x:Name="tooltip">
<TextBlock x:Name="tblock" Text="{Binding Value}" />
</ToolTip>
</ToolTipService.ToolTip>
</telerik:RadMaskedTextInput>
public
MainWindow()
{
InitializeComponent();
this.tooltip.DataContext = this.maskedInput;
}
Solution 2)
<
telerik:RadMaskedTextInput
x:Name
=
"maskedInput"
Style="{StaticResource RadMaskedTextInputKey}"
TextBoxStyle="{StaticResource textboxTrimming}"
MaxHeight="40"
Mask=""
Value="abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvw"
ToolTipService.ToolTip="{Binding Value, ElementName=maskedInput}">
Regards,
Petar Mladenov
Telerik
See What's Next in App Development. Register for TelerikNEXT.