private void AssociatedObjectOnLoaded(object sender, RoutedEventArgs routedEventArgs) { if (this.ExistsFocusedControlWithHigherFocusPrio()) { return; } IInputElement inputElement; if (this.TargetType == null) { inputElement = this.AssociatedObject.FindChild <IInputElement>(this.IsValidInputElement); } else { inputElement = this.AssociatedObject.FindChild(this.IsValidElement, this.TargetType) as IInputElement; } var waitIndicatorKey = new BusyIndicatorNotice(); Action setFocus = () => Keyboard.Focus(inputElement); waitIndicatorKey.ExecuteActionIfBulletinAllowsIt(setFocus); this.AssociatedObject.Loaded -= this.AssociatedObjectOnLoaded; }
private static void OnIsFocusedPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var uie = (FrameworkElement)d; if ((bool)e.NewValue && uie.Dispatcher != null) { Action setFocusAction = () => SetNewFocus(uie); var waitIndicatorKey = new BusyIndicatorNotice(); waitIndicatorKey.ExecuteActionIfBulletinAllowsIt(setFocusAction); } }
private static void OnSourcePropertyNameChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var uie = (FrameworkElement)d; if (!string.IsNullOrEmpty((string)e.NewValue) && uie.Dispatcher != null) { var elementToFocus = uie.FindChildWithTargetPropertyNameBinding((string)e.NewValue); if (elementToFocus != null) { Action setFocusAction = () => SetNewFocus(elementToFocus, uie); var waitIndicatorKey = new BusyIndicatorNotice(); waitIndicatorKey.ExecuteActionIfBulletinAllowsIt(setFocusAction); } } }