Beispiel #1
0
 void AssociatedObjectFocus()
 {
     if (AssociatedObject.Focusable && AssociatedObject.IsTabStop)
     {
         AssociatedObject.Focus();
     }
     else
     {
         var children       = LayoutTreeHelper.GetVisualChildren(AssociatedObject);
         var controlToFocus = children.OfType <Control>().Where(x => x.Focusable && x.IsTabStop).FirstOrDefault();
         controlToFocus.Do(x => x.Focus());
     }
 }
Beispiel #2
0
 internal static void UpdateWindowOwner(Window w, FrameworkElement ownerObject)
 {
     if (ownerObject == null)
     {
         return;
     }
     if (!ViewModelBase.IsInDesignMode)
     {
         w.Owner = LayoutTreeHelper.GetVisualParents(ownerObject).OfType <Window>().FirstOrDefault()
                   ?? Window.GetWindow(ownerObject);
     }
     else
     {
         System.Windows.Interop.WindowInteropHelper windowInteropHelper = new System.Windows.Interop.WindowInteropHelper(w);
         windowInteropHelper.Owner = GetActiveWindow();
     }
 }
 protected virtual FrameworkElement FindParent(object sender, DependencyObject originalSource)
 {
     return(LayoutTreeHelper.GetVisualParents(originalSource, (DependencyObject)sender).Where(CheckItemType(sender)).FirstOrDefault() as FrameworkElement);
 }