csShared.Controls.Popups.MapCallOut.MapCallOutViewModel.DoSimulateFocusChange C# (CSharp) Method

DoSimulateFocusChange() public static method

When binding a property to a textbox/combox the property is not updated when a menu item is selected (because this doesn't cause a focus change) This method writes the value in the gui to the property from the active element!
public static DoSimulateFocusChange ( ) : void
return void
        public static void DoSimulateFocusChange()
        {
            TextBox textBox = Keyboard.FocusedElement as TextBox;

            if (textBox != null)
            {
                BindingExpression be = textBox.GetBindingExpression(TextBox.TextProperty);
                if (be != null && !textBox.IsReadOnly && textBox.IsEnabled)
                {
                    be.UpdateSource();
                }
                return;
            }
            ComboBox lComboBox = Keyboard.FocusedElement as ComboBox;

            if (lComboBox != null)
            {
                BindingExpression be = lComboBox.GetBindingExpression(ComboBox.TextProperty);
                if (be != null && !lComboBox.IsReadOnly && lComboBox.IsEnabled)
                {
                    be.UpdateSource();
                }
                return;
            }

           
        }