Beispiel #1
0
 private bool TryToSetFocus(DependencyObject element)
 {
     if (element is Control)
     {
         ((Control)element).Focus();
         return true;
     }
     for (int i = 0; i < element.CountVisualChildren(); i++)
     {
         if (TryToSetFocus(element.VisualChild(i)))
         {
             return true;
         }
     }
     return false;
 }