private void OnBrowserNavigated(object sender, System.Windows.Navigation.NavigationEventArgs e) { WebAddress = e.Uri == null ? "" : e.Uri.OriginalString; var doc = Browser.Browser.Document as HTMLDocument; Header = doc.title == "" ? Header : doc.title; ForwardCommand.RaiseCanExecuteChanged(); BackCommand.RaiseCanExecuteChanged(); }
/// <inheritdoc/> protected override void OnPropertyChanged(PropertyChangedEventArgs eventArgs) { if (InspectCommand != null) // Method is called in constructor before commands are set. { InspectCommand.RaiseCanExecuteChanged(); BackCommand.RaiseCanExecuteChanged(); RefreshCommand.RaiseCanExecuteChanged(); CopyValueCommand.RaiseCanExecuteChanged(); } base.OnPropertyChanged(eventArgs); }
private void SetFrame(Frame frame) { if (BackCommand != null) { BackCommand.CanExecuteChanged -= OnCanExecuteChanged; } BackCommand = new BackCommand(frame); BackCommand.CanExecuteChanged += OnCanExecuteChanged; BackCommand.RaiseCanExecuteChanged(); }
private void ExecuteNav(NavType navType) { var type = navType.Type; _contentFrame.Navigate(navType.Type, navType.Parameter); // when we nav home, clear history if (type == typeof(HomePage)) { _contentFrame.BackStack.Clear(); BackCommand?.RaiseCanExecuteChanged(); } }
public async Task SetPage() { CollapseTab(); await Task.Factory.StartNew(() => { DispatcherHelper.CheckBeginInvokeOnUI(() => { if (CurrentPage != null) { CurrentPage.OnNavigatedFrom(); } }); }); await Task.Delay(250); await Task.Factory.StartNew(() => { DispatcherHelper.CheckBeginInvokeOnUI(() => { CurrentPage = _navigationHistory.Peek(); }); }); await Task.Delay(200); ExpandTab(); await Task.Factory.StartNew(() => { DispatcherHelper.CheckBeginInvokeOnUI(() => { CurrentPage.OnNavigatedTo(); BackCommand.RaiseCanExecuteChanged(); OpenSettingsCommand.RaiseCanExecuteChanged(); }); }); }
public virtual void OnNavigatedTo(NavigationContext navigationContext) { RegionNavigationService = navigationContext.NavigationService; BackCommand.RaiseCanExecuteChanged(); ForwardCommand.RaiseCanExecuteChanged(); }
private void Frame_Navigated(object sender, NavigationEventArgs e) { if (e.NavigationMode == Windows.UI.Xaml.Navigation.NavigationMode.Refresh) { return; } var frame = (Frame)sender; BackCommand.RaiseCanExecuteChanged(); MyNavigtionView.IsPaneVisible = !MenuPaneHiddenPageTypes.Any(x => x == e.SourcePageType); if (MyNavigtionView.IsPaneVisible) { var sourcePageTypeName = e.SourcePageType.Name; if (e.SourcePageType == typeof(FolderListupPage)) { sourcePageTypeName = nameof(Views.SourceStorageItemsPage); } var selectedMeuItemVM = ((List <object>)MyNavigtionView.MenuItemsSource).FirstOrDefault(x => (x as MenuItemViewModel)?.PageType == sourcePageTypeName); if (selectedMeuItemVM != null) { MyNavigtionView.SelectedItem = selectedMeuItemVM; } } // 戻れない設定のページではバックナビゲーションボタンを非表示に切り替え var isCanGoBackPage = CanGoBackPageTypes.Contains(e.SourcePageType); SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = isCanGoBackPage ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed ; // 戻れない設定のページに到達したら Frame.BackStack から不要なPageEntryを削除する if (!isCanGoBackPage) { ContentFrame.BackStack.Clear(); BackParametersStack.Clear(); if (e.NavigationMode == Windows.UI.Xaml.Navigation.NavigationMode.New) { ContentFrame.ForwardStack.Clear(); ForwardParametersStack.Clear(); } _ = StoreNaviagtionParameterDelayed(); } else if (!_isFirstNavigation) { // ここのFrame_Navigatedが呼ばれた後にViewModel側のNavigatingToが呼ばれる // 順序重要 _Prev = PrimaryWindowCoreLayout.CurrentNavigationParameters; // ビューワー系ページはバックスタックに積まれないようにする // ビューワー系ページを開いてる状態でアプリ外部からビューワー系ページを開く操作があり得る bool rememberBackStack = true; if (ForgetOwnNavigationPageTypes.Any(type => type == e.SourcePageType)) { var lastNavigatedPageEntry = frame.BackStack.LastOrDefault(); if (ForgetOwnNavigationPageTypes.Any(type => type == lastNavigatedPageEntry?.SourcePageType) && e.SourcePageType == lastNavigatedPageEntry?.SourcePageType ) { frame.BackStack.RemoveAt(frame.BackStackDepth - 1); rememberBackStack = false; } } if (e.NavigationMode != Windows.UI.Xaml.Navigation.NavigationMode.New) { rememberBackStack = false; } if (rememberBackStack) { ForwardParametersStack.Clear(); var parameters = new NavigationParameters(); if (_Prev != null) { foreach (var pair in _Prev) { if (pair.Key == PageNavigationConstants.Restored) { continue; } parameters.Add(pair.Key, pair.Value); } } BackParametersStack.Add(parameters); } _ = StoreNaviagtionParameterDelayed(); } _isFirstNavigation = false; }
public AppShell(Frame frame) { _contentFrame = frame; InitializeComponent(); ShellSplitView.Content = frame; var update = new Action(() => { // update radiobuttons after frame navigates var type = frame.CurrentSourcePageType; foreach (var radioButton in AllRadioButtons(this)) { var target = radioButton.CommandParameter as NavType; if (target == null) { continue; } radioButton.IsChecked = target.Type == type; } if (ShellSplitView.DisplayMode != SplitViewDisplayMode.CompactInline) { ShellSplitView.IsPaneOpen = false; } BackCommand.RaiseCanExecuteChanged(); }); frame.Navigated += (s, e) => update(); Loaded += delegate { Current = this; update(); if (_isWindowsPhone) { btnHamburger.Background = null; } }; SizeChanged += AppShell_SizeChanged; rbBack.Visibility = Visibility.Collapsed; btnBack.Visibility = (_isWindowsPhone) ? Visibility.Collapsed : Visibility.Visible; if (_isWindowsPhone) { HardwareButtons.BackPressed += delegate(object sender, BackPressedEventArgs e) { if (CanBack()) { e.Handled = true; ExecuteBack(); } }; ShellSplitView.DisplayMode = SplitViewDisplayMode.Overlay; } else { ShellSplitView.DisplayMode = SplitViewDisplayMode.CompactOverlay; } if (_isWindowsPhone) { btnHamburger.Foreground = new SolidColorBrush(Colors.Black); } DataContext = this; }