Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > NumericUpDown > UpdateSource to NumericUpDown

Not answered UpdateSource to NumericUpDown

Feed from this thread
  • Cheau-Long avatar

    Posted on Jun 13, 2011 (permalink)

    Hi Telerik,

    When the RadNumericUpDown is in focus, I'd like to update the source in VM. I created a simple method to grab the focused element from the keyboard and update the source. The problem is the Keyboard.FocusedElement returned a type called PickerTextBox instead of RadNumericUpDown and thus the highlighted codes won't be fired. My question is how I can UpdateSource to NumericUpDown properly? The original problem is when the RadNumericUpDown is in focus and user saves the app, the RadNumericUpDown source won't be updated.

            private void UpdateFocusedTextBox()

            {

                //There is an issue when textbox is in focus, it won't update the source.

                //This workaround will try to find the currently focusedTextBox and update the source.

                object focusedTextBox = Keyboard.FocusedElement;

     

                if (focusedTextBox is RadNumericUpDown)

                {

                    RadNumericUpDown rad = focusedTextBox as RadNumericUpDown;

                    ((RadNumericUpDown)focusedTextBox).GetBindingExpression(RadNumericUpDown.ValueProperty).UpdateSource();

                }           

                else if(focusedTextBox is TextBox)

                    ((TextBox)focusedTextBox).GetBindingExpression(TextBox.TextProperty).UpdateSource();        

            }

    Reply

  • Pana Pana admin's avatar

    Posted on Jun 16, 2011 (permalink)

    Hello,

    This happens because in fact the PickerTextBox inside the RadNumericUpDown is focused. If you want to get the RadNumericUpDown that the PickerTextBox belongs to you can use the Telerik.Windows.Controls UIElement's extension method for ParentOfType<RadNumericUpDown>(). If the method returns a RadNumericUpDown then you can use it to get the value.

    All the best,
    Pana
    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

  • Cheau-Long avatar

    Posted on Jun 16, 2011 (permalink)

    It worked! Thanks very much.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > NumericUpDown > UpdateSource to NumericUpDown
Related resources for "UpdateSource to NumericUpDown"

WPF NumericUpDown Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]