UI doesn't update with PadLeft

6 posts, 1 answers
  1. yijie
    yijie avatar
    14 posts
    Member since:
    Jul 2011

    Posted 29 Aug 2011 Link to this post

    Hi,

    I want to do the PadLeft within the MashedInput control and i do it as below. However i found out that the UI doesn't update and refresh itself whereas the private backup field has changed.  When i create another control binding to the same property it will update when i inpute something into the MashedInput control.

    In short the MashedInput control don't refresh itself when the databinding source change. Please help me there.

    GUI

     

    <telerik:RadMaskedTextInput 
                Value="{Binding Number, Mode=TwoWay}" Mask="###" UpdateValueEvent="LostFocus"    
                HorizontalAlignment="Left" Margin="12,12,0,0" Name="radMaskedTextInput1" VerticalAlignment="Top" Width="75" />

    Codebehind

    public class VM : ViewModelBase
       {
           private string _Number = "";
           public string Number 
           
               get
               {
                   return this._Number;   
               }
               set
               {
                   value = value.PadLeft(3, '0');
                   if (value != this._Number)
                   {
                       this._Number = value;
                       RaisePropertyChanged("Number");
                   }
               }
           }
       }
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 01 Sep 2011 Link to this post

    Hi Yijie,

     Can you confirm that you use the Telerik's ViewModelBase class. It has OnPropertyChanged method, not RaisePropertyChanged. I prepared a sample for you demonstrating this. Please let us know if it satisfies you.

    Greetings,
    Petar Mladenov
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. DevCraft banner
  4. yijie
    yijie avatar
    14 posts
    Member since:
    Jul 2011

    Posted 01 Sep 2011 Link to this post

    Hi Petar,

    Thanks for your reply. However your sample code still not meet my requirement.

    Here i want. If user input __1 then invoking the lostfocus event then the binding source will be set to 001 right? However the UI doesn't update at all it still dispaly __1. When i use common textbox control it works fine.

    Please help me there.

    Regards,

    Alex Fan
  5. yijie
    yijie avatar
    14 posts
    Member since:
    Jul 2011

    Posted 01 Sep 2011 Link to this post

    Hi Petar,

    Thanks for your reply. However your sample code still not meet my requirement.

    Here i want. If user input __1 then invoking the lostfocus event then the binding source will be set to 001 right? However the UI doesn't update at all it still dispaly __1. When i use common textbox control it works fine.

    private void Button_Click(object sender, RoutedEventArgs e) 
        (this.radMaskedTextInput1.DataContext as VM).Number = "1"
    }

    Besides the code above works fine no matter i use myown base class or  Telerik's ViewModelBase, it doesn't work only if you input the number inside the control. Pls have a try.

    Please help me there.

    Regards,

    Alex Fan
  6. Answer
    Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 03 Sep 2011 Link to this post

    Hi Yijie,

    I logged this issue in our PITS as a bug. You can track its progress from here.

    In the meantime as a workaround you can define a ValueToTextConverter to display 001 in the MaskedTextInput control when the user enters 1.

    Regards,
    Tina Stancheva
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  7. yijie
    yijie avatar
    14 posts
    Member since:
    Jul 2011

    Posted 04 Sep 2011 Link to this post

    Hi Tina,

    Thanks for your reply and workaround solution. I shall track this issue and looking forwards to the fxied version.

Back to Top
DevCraft banner