Exemplo n.º 1
0
        public static FrameworkElement FindBlockNavigatorElement(FrameworkElement elm)
        {
            var searchElm = elm;

            DependencyObject GetParent(FrameworkElement child)
            {
                return(child.Parent ??
                       child.TemplatedParent ??
                       System.Windows.Media.VisualTreeHelper.GetParent(child));
            }

            // if we query the navigator on a nested element, make sure we get the parent navigator and not the self
            if (BlockNavigatorProperty.GetIsNestedNavigation(searchElm) && GetParent(searchElm) != null)
            {
                searchElm = (FrameworkElement)GetParent(searchElm);
            }

            while (true)
            {
                var parent = GetParent(searchElm);

                if (parent == null)
                {
                    return(searchElm);
                }

                var isNestedNavigator = BlockNavigatorProperty.GetIsNestedNavigation(searchElm);
                if (isNestedNavigator)
                {
                    return(searchElm);
                }

                searchElm = (FrameworkElement)parent;
            }
        }
Exemplo n.º 2
0
        private void OnConfirmClick(int player, GamePadState state)
        {
            _focusElement?.Dispatcher.Invoke(() => {
                OwnerElement?.RaiseEvent(new RoutedEventArgs(BlockNavigatorProperty.ConfirmClickEvent, OwnerElement));
                _focusElement?.RaiseEvent(new RoutedEventArgs(BlockNavigatorProperty.ConfirmClickEvent, _focusElement));
                if (BlockNavigatorProperty.GetSimulateMouse(_focusElement))
                {
                    SimulateMouse(_focusElement);
                }

                if (BlockNavigatorProperty.GetIsNestedNavigation(_focusElement))
                {
                    ActivateNestedNavigator(_focusElement);
                }
            });
        }