Пример #1
0
        private void NavigateToGame()
        {
            var mainWindow = VisualTreeHelperExtensions.FindParent <MainWindow>(this);

            if (mainWindow == null)
            {
                return;
            }

            var mainViewModel = (MainViewModel)mainWindow.DataContext;

            mainViewModel.NavigateViewCommand.Execute("Game");
        }
Пример #2
0
        private static void OnIsApplicationBarHostChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            var host = obj as Decorator;

            if (host != null)
            {
                var window = VisualTreeHelperExtensions.FindParent <System.Windows.Window>(host);
                if (window != null)
                {
                    var applicationBar = GetApplicationBar(window);
                    host.Child = BooleanBoxingHelper.Unbox(e.NewValue) ? applicationBar : null;
                }
            }
        }
Пример #3
0
        private static void OnPreviewMouseButtonOutsideCapturedElement(object sender, MouseButtonEventArgs e)
        {
            var instance = sender as ApplicationBar;
            var source   = e.OriginalSource as DependencyObject;

            if (instance != null && source != null && !instance.StaysOpen)
            {
                var visualParent  = VisualTreeHelperExtensions.FindParent <ApplicationBar>(source);
                var logicalParent = LogicalTreeHelperExtensions.FindParent <ApplicationBar>(source);
                if (!(Equals(instance, visualParent) || Equals(instance, logicalParent)))
                {
                    instance.IsOpen = false;
                }
            }
        }
Пример #4
0
        private static void OnLostMouseCapture(object sender, MouseEventArgs e)
        {
            var instance = sender as ApplicationBar;
            var source   = e.OriginalSource as DependencyObject;

            if (instance != null && source != null && !instance.StaysOpen)
            {
                var visualParent  = VisualTreeHelperExtensions.FindParent <ApplicationBar>(source);
                var logicalParent = LogicalTreeHelperExtensions.FindParent <ApplicationBar>(source);
                if (Equals(instance, visualParent) || Equals(instance, logicalParent) || (Mouse.Captured == null && instance.IsOpen))
                {
                    Mouse.Capture(instance, CaptureMode.SubTree);
                    e.Handled = true;
                }
            }
        }