Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > MaskedTextBox > Bug with UpdateValueEvent

Not answered Bug with UpdateValueEvent

Feed from this thread
  • André avatar

    Posted on Oct 22, 2010 (permalink)

    Wen I set the UpdateValueEvent to LostFocus, the control only display text wen got focus.

    I have the following code:
    <telerik:RadMaskedTextBox Value="{Binding Cpf, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"
    Margin="0,0,10,8" Mask="###.###.###-##" UpdateValueEvent="LostFocus"/>

    If i remove the UpdateValueEvent everthing works fine.

    Reply

  • Alex Fidanov Alex Fidanov admin's avatar

    Posted on Oct 27, 2010 (permalink)

    Hi André,

    The UpdateValueEvent property is used to determine when the value of the RadMaskedTextBox should be updated based on the input. When set to LostFocus, the value will be updated when the control loses focus. Could you please give us more information on the Cpf property and when it updates?

    Greetings,
    Alex Fidanov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

    Reply

  • André avatar

    Posted on Oct 28, 2010 (permalink)

    i made this code just to example the issue i'm having on my current project. 

    Cpf is a simple property, like above:
    public class Context
        {
            private string _Cpf;
     
            public string Cpf
            {
                get { return "111111111111"; }
                set { _Cpf = value; }
            }
        }

    and my codebehind:
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            this.DataContext = new Context();
        }
    }

    this is all code i used do get this issue

    Reply

  • Alex Fidanov Alex Fidanov admin's avatar

    Posted on Nov 2, 2010 (permalink)

    Hi André,

    When the UpdateValueEvent is set to LostFocus, the RadMaskedTextBox will try to update the value when the control loses focus. Unlike PropertyChanged, this will not trigger until the control loses focus. What you can do is to use PropertyChagned option in the beginning and then switch to lost focus. You can do this in the RadMaskedTextBox's Loaded event, like this :

    void RadMaskedTextBox_Loaded(object sender, RoutedEventArgs e)
            {
                this.Dispatcher.BeginInvoke(() =>
                {
                    radMaskedTextBox.UpdateValueEvent = Telerik.Windows.Controls.UpdateValueEvent.LostFocus;
                });
            }
    We are currently refactoring the RadMaskedTextBox control and this issue will be resolved in the future releases.

    All the best,
    Alex Fidanov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

    Reply

  • Josh avatar

    Posted on Jun 22, 2011 (permalink)

    Has this been fixed yet?

    Reply

  • Tina Stancheva Tina Stancheva admin's avatar

    Posted on Jun 24, 2011 (permalink)

    Hello Josh,

    Unfortunately this issue isn't addressed yet due to the many pressing tasks in our to-do list.

    However,  we released a new suite of MaskedInput controls dedicated to working with different kind of input. You can examine their demo here. And in the case described in this forum post, you can definitely take advantage of the new MaskedTextInput control, where this issue is resolved.
    <telerik:RadMaskedTextInput Value="{Binding Cpf, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"
            Margin="0,0,10,8" Mask="###.###.###-##" UpdateValueEvent="LostFocus" />
     Please give it a try and let us know if it work for you.

    Regards,
    Tina Stancheva
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

    Reply

  • Paurav avatar

    Posted on Jun 24, 2011 (permalink)

    Hi,

    I used the workaround you stated, but in doing that, the RadMaskedTextBox control tries to update the property when it loads the first time and since it's empty, my validation kicks in. It shouldn't be updating the value when it loads even if UpdateValueEvent="PropertyChanged" since nothing has changed.

    Thanks
    Paurav

    Reply

  • Alex Fidanov Alex Fidanov admin's avatar

    Posted on Jun 29, 2011 (permalink)

    Hello Paurav,

    In the validation (or in the setter of your property) you can check if the previous value is different than the new value. If they are, then you can trigger the validation. Even though the RadMaskedTextBox calls the setter, it would be with the same value as the that property field's value. However, if the mask of the RadMaskedTextBox does not is not appropriate for the value, then it would trim or modify the value so that it satisfies the mask.

    Kind regards,
    Alex Fidanov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

    Reply

  • Posted on Oct 19, 2011 (permalink)

    I had a similar issue but was able to solve it by doing the following (note that this was in a custom class that inherited from RadMaskedTextBox)

    1. Don't set the UpdateValueEvent initally
    2. Add event handlers for GotFocus and LostFocus
    3. In your GotFocus event handler, set UpdateValueEvent = UpdateValueEvent.LostFocus;
    4. In your LostFocus event handler, set UpdateValueEvent = UpdateValueEvent.PropertyChanged;

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > MaskedTextBox > Bug with UpdateValueEvent
Related resources for "Bug with UpdateValueEvent"

Silverlight MaskedTextBox Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]