This is a migrated thread and some comments may be shown as answers.

Text --> Value

8 Answers 71 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
Marc
Top achievements
Rank 1
Marc asked on 09 Feb 2012, 04:53 PM
Let's assume the following XAML:

<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

Sort by
0
Alex Fidanov
Telerik team
answered on 14 Feb 2012, 01:04 PM
Hi,

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
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Michael Salzlechner
Top achievements
Rank 1
answered on 19 Mar 2012, 02:18 PM
we have the same problem. We are storing formatted strings in the database and want the user to be able to edit them using maskedinput.

is this something that is planned for support ?
0
Tina Stancheva
Telerik team
answered on 22 Mar 2012, 10:03 AM
Hello Michael,

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.
And as the Text property is formed based on the Value property, with the current implementation of the MaskedInput controls the reversed scenario cannot be supported. This is why you'll need to strip off your formatted value - so that you can pass it to the Value property of the controls.

Regards,
Tina Stancheva
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Marc
Top achievements
Rank 1
answered on 22 Mar 2012, 10:07 AM
Hello Tina,

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
0
Tina Stancheva
Telerik team
answered on 22 Mar 2012, 10:41 AM
Hello 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
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Marc
Top achievements
Rank 1
answered on 22 Mar 2012, 10:42 AM
Perfect, thank your for this great support.
0
Dan
Top achievements
Rank 1
answered on 06 Apr 2015, 08:25 PM

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>

0
Petar Mladenov
Telerik team
answered on 08 Apr 2015, 11:57 AM
Hi Steve,

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.

 
Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
Marc
Top achievements
Rank 1
Answers by
Alex Fidanov
Telerik team
Michael Salzlechner
Top achievements
Rank 1
Tina Stancheva
Telerik team
Marc
Top achievements
Rank 1
Dan
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or