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

UI doesn't update with PadLeft

5 Answers 92 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
yijie
Top achievements
Rank 1
yijie asked on 30 Aug 2011, 02:58 AM
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");
               }
           }
       }
   }

5 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 01 Sep 2011, 02:11 PM
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 >>

0
yijie
Top achievements
Rank 1
answered on 01 Sep 2011, 02:27 PM
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
0
yijie
Top achievements
Rank 1
answered on 01 Sep 2011, 02:34 PM
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
0
Accepted
Tina Stancheva
Telerik team
answered on 03 Sep 2011, 12:27 PM
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 >>

0
yijie
Top achievements
Rank 1
answered on 05 Sep 2011, 01:56 AM
Hi Tina,

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

Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
yijie
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
yijie
Top achievements
Rank 1
Tina Stancheva
Telerik team
Share this question
or