private static void SetNavigationFocusElement(FrameworkElement focusedElement)
        {
            Visual navigationScope = GetNavigationScope(focusedElement);

            if (navigationScope != null)
            {
                VisualWeakReference visualWeakReference = GetNavigationFocusElement(focusedElement);
                SetNavigationFocusElement(navigationScope, new VisualWeakReference(focusedElement, navigationScope));
            }
        }
Beispiel #2
0
            public override IEnumerable <Stop> GetGlobalStops(Visual scope, Visual currentElement, DependencyProperty navigationModeProperty)
            {
                if (IsStop((UIElement)scope) || scope == currentElement)
                {
                    yield return(new Stop(scope));
                }

                VisualWeakReference navigationFocusElementReference = KeyboardNavigation.GetNavigationFocusElement(scope);
                Visual navigationFocusElement = navigationFocusElementReference != null ? navigationFocusElementReference.Visual : null;

                Stop[] stops = scope.VisualChildren.SelectMany(child => KeyboardNavigationTarget.GetGlobalStops(child, currentElement, navigationModeProperty)).ToArray();

                if (stops.Any())
                {
                    stops = stops.Where(stop => stop.Element == currentElement || stop.Element == navigationFocusElement).DefaultIfEmpty(stops.First()).ToArray();

                    foreach (Stop stop in stops)
                    {
                        yield return(stop);
                    }
                }
            }
 public static void SetNavigationFocusElement(DependencyObject obj, VisualWeakReference value)
 {
     obj.SetValue(NavigationFocusElementProperty, value);
 }