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();
}