Text --> Value

9 posts, 0 answers
  1. Marc
    Marc avatar
    88 posts
    Member since:
    Jul 2011

    Posted 09 Feb 2012 Link to this post

    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
  2. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 14 Feb 2012 Link to this post

    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 >>
  3. DevCraft banner
  4. Michael Salzlechner
    Michael Salzlechner avatar
    41 posts
    Member since:
    Jan 2010

    Posted 19 Mar 2012 Link to this post

    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 ?
  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 22 Mar 2012 Link to this post

    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 >>
  6. Marc
    Marc avatar
    88 posts
    Member since:
    Jul 2011

    Posted 22 Mar 2012 Link to this post

    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
  7. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 22 Mar 2012 Link to this post

    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 >>
  8. Marc
    Marc avatar
    88 posts
    Member since:
    Jul 2011

    Posted 22 Mar 2012 Link to this post

    Perfect, thank your for this great support.
  9. Dan
    Dan avatar
    6 posts
    Member since:
    Jan 2015

    Posted 06 Apr 2015 in reply to Tina Stancheva Link to this post

    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>

  10. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 08 Apr 2015 Link to this post

    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.

     
Back to Top
DevCraft banner