Exemplo n.º 1
0
        private void NavigateToGame()
        {
            var mainWindow = VisualTreeHelperExtensions.FindParent <MainWindow>(this);

            if (mainWindow == null)
            {
                return;
            }

            var mainViewModel = (MainViewModel)mainWindow.DataContext;

            mainViewModel.NavigateViewCommand.Execute("Game");
        }
Exemplo n.º 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;
                }
            }
        }
Exemplo n.º 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;
                }
            }
        }
Exemplo n.º 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;
                }
            }
        }