Calling BindinExpression.UpdateSource() doesn't update bound property

3 posts, 0 answers
  1. Scott
    Scott avatar
    66 posts
    Member since:
    Nov 2009

    Posted 09 Mar 2011 Link to this post

    I have a few RadNumericUpDown controls bound in TwoWay mode to properties. I have the following code that does get called when the KeyUp event occurs:
    private void KeyUp(object sender, KeyEventArgs e)
    {
        FrameworkElement fe = (FrameworkElement) sender;
        BindingExpression exp;
        if (fe is TextBox)
        {
            exp = fe.GetBindingExpression(TextBox.TextProperty);
        }
        else if (fe is RadNumericUpDown)
        {
            exp = fe.GetBindingExpression(RadRangeBase.ValueProperty);
        }
        else
        {
            throw new Exception("Invalid type");
        }
          
        exp.UpdateSource();
    }

    If I use this code on a TextBox the source is updated with the correct value but if I use a RadComboBox it does not update the source. What am I doing wrong?

    What I'm trying to accomplish is to update all my bindings whenever a change is made to the RadNumericUpDown control without having to lose focus on the control. Pressing the up/down buttons in the control do update my bindings but typing numbers in the control do not until the contolr loses focus.
  2. Scott
    Scott avatar
    66 posts
    Member since:
    Nov 2009

    Posted 09 Mar 2011 Link to this post

    I figured it out. I just needed to change the UpdateValueEvent like so
    UpDown1.UpdateValueEvent = UpdateValueEvent.PropertyChanged;
    Thanks for listening to me ramble :-)
  3. DevCraft banner
  4. sivakanth
    sivakanth avatar
    50 posts
    Member since:
    Dec 2010

    Posted 12 Apr 2011 Link to this post

    Hi Scott ,
                  How to Update RadcomboBox value without losing Focus?
    can u give me details..my mail id is s.sivakanth@gmail.com
Back to Top