Update Bound Property on Lost Focus

2 posts, 0 answers
    WILLIAM avatar
    134 posts
    Member since:
    Jun 2012

    Posted 07 Feb 2013 Link to this post

    I'm trying to use a NumericInput control and can't seem to figure out how to get it to behave properly.  Even though I have UpdateValueEvent="LostFocus", it doesn't always update the bound property.  Setting UpdateValueEvent="PropertyChanged" works the same way.  In order to Update the value to 1, I have enter 0001.  Also, if I clear the text, the value does not update to blank

    I have RadGrid and View that are bound to the same object.  The bound property for this control is int?

    See my attached screen shots:
    #1 Shows a new record being entered and I'm about to change the "From" value.
    #2 Shows that I entered a value of 1234 and tabbed to Year Graduated.  (Expected Behavior)
    #3 Shows that I changed the value in "From" to 1 and tabbed to Year Graduated.  However, the value in the grid did not update, and if I inspect bound object, it is still set to 1234 even though the value on the form has been changed to 1.
    #4 Shows that I have enter 0001 to update the value to 1.
    #5 Shows that I have "From" value has been cleared, but the value in the grid did not change

    How do I set this control up to be able to:
    1. Enter any positive (up to 4 digits)
    2. Allow the user to clear/blank out/remove an existing value
    3. No matter what, when the control loses focus, the underlying bound property is updated.

    Here is how I currently have the control configured.
    <telerik:RadMaskedNumericInput Name="uxFrom" Mask="#4" TextMode="MaskedText"
                                   InputBehavior="Insert" SelectionOnFocus="CaretToBeginning"                                               
                                   UpdateValueEvent="LostFocus" IsClearButtonVisible="False"
                                   Grid.Row="3" Grid.Column="5" Grid.ColumnSpan="1" Margin="0,0,4,0"/>

    Thanks for your help!
  2. Petar Mladenov
    Petar Mladenov avatar
    2882 posts

    Posted 12 Feb 2013 Link to this post


     I cannot see your Value property two-way bound to a ViewModel's property. I guess you need the following configuration:
    MaskedNumericInput.Value <-2 way bound --> double property from your ViewModel -->bound to GridView Cell
    For a successful result, you have to ensure:

    • two-way binding between Value and the double property from your viewmodel
    • OnPropertyChanged() to fire when the ViewModel's Property is re-set, changed (this will update the value displayed in the GridView)
    • the property in the VM should be nullabale double (double?), this way when you press the clear button the value in the viewmodel will be null
    Let us know if this help you proceed further or not.
    All the best,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft R3 2016 release webinar banner
Back to Top