private void NavigateToGame() { var mainWindow = VisualTreeHelperExtensions.FindParent <MainWindow>(this); if (mainWindow == null) { return; } var mainViewModel = (MainViewModel)mainWindow.DataContext; mainViewModel.NavigateViewCommand.Execute("Game"); }
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; } } }
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; } } }
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; } } }