private void TryGoBack() { if (NavigationService.CanGoBack()) { NavigationService.GoBack(); } }
public PageViewModelBase(INavigationService navigationService, IAlertMessageService alertMessageService, IResourceLoader resourceLoader, IAppSettingsService appSettingsService) { _navigationService = navigationService; _alertMessageService = alertMessageService; _resourceLoader = resourceLoader; _appSettingsService = appSettingsService; _viewModelMapper = new BusinessObjectDataViewModelMapper(resourceLoader); NavigateHomeCommand = new DelegateCommand(NavigateToMain); ToggleFlyoutCommand = new DelegateCommand(ToggleFlyout); FlyoutVisibility = Visibility.Collapsed; InitActionFunctions(); #if WINDOWS_APP if (NavigationService.CanGoBack()) { // default back command BackCommand = new DelegateCommand(() => NavigationService.GoBack()); } #endif }
private void NavigationService_NavigatedToPage(object sender, NavigatedEventArgs e) { var navigatedNode = Navigation.FindPage(e.Page); if (navigatedNode != null) { Navigation.Active = navigatedNode; } else { Navigation.Active = null; } if (NavPanelOpened) { NavPanelOpened = false; } if (NavigationService.CanGoBack()) { SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; } else { SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; } OnPropertyChanged("GoBackCommand"); }
public ShellViewModel() { Navigation = new AppNavigation(); Navigation.LoadNavigation(); if (Window.Current.Bounds.Width < 800) { this.SplitViewDisplayMode = SplitViewDisplayMode.Overlay; } else { this.SplitViewDisplayMode = SplitViewDisplayMode.CompactOverlay; } HamburguerButtonVisibility = Visibility.Visible; SetHamburguerButtonVisibility += ((sender, hamburguerButtonVisibility) => { HamburguerButtonVisibility = hamburguerButtonVisibility; }); Window.Current.SizeChanged += WindowSizeChanged; NavigationService.NavigatedToPage += NavigationService_NavigatedToPage; FullScreenService.FullScreenModeChanged += FullScreenModeChanged; SystemNavigationManager.GetForCurrentView().BackRequested += ((sender, e) => { if (NavigationService.CanGoBack()) { e.Handled = true; NavigationService.GoBack(); } }); }
public ShellViewModel() { Navigation = new AppNavigation(); Navigation.LoadNavigation(); if (Window.Current.Bounds.Width < 800) { this.SplitViewDisplayMode = SplitViewDisplayMode.Overlay; } else { this.SplitViewDisplayMode = SplitViewDisplayMode.CompactOverlay; } Window.Current.SizeChanged += ((args, e) => { WindowSizeChanged(e.Size.Width); }); NavigationService.NavigatedToPage += NavigationService_NavigatedToPage; FullScreenService.FullScreenModeChanged += FullScreenModeChanged; SystemNavigationManager.GetForCurrentView().BackRequested += ((sender, e) => { if (NavigationService.CanGoBack()) { FullScreenService.ExitFullScreenMode(); e.Handled = true; NavigationService.GoBack(); } }); }
/// <summary> /// Invoked when the hardware back button is pressed. For Windows Phone only. /// </summary> /// <param name="sender">Instance that triggered the event.</param> /// <param name="e">Event data describing the conditions that led to the event.</param> private void HardwareButtons_BackPressed(object sender, Windows.Phone.UI.Input.BackPressedEventArgs e) { if (NavigationService.CanGoBack()) { e.Handled = true; NavigationService.GoBack(); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected virtual void OnNavigated(object sender, NavigationEventArgs e) { if (DeviceGestureService.UseTitleBarBackButton) { SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = NavigationService.CanGoBack() ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed; } }
private async void NavManager_BackRequested(object sender, BackRequestedEventArgs e) { if (NavigationService.CanGoBack()) { e.Handled = true; await NavigationService.GoBackAsync(); } }
private void DoSearch() { if (NavigationService.CanGoBack()) { NavigationService.GoBack(); } else { NavigationService.NavigateToPlanner(string.Empty); } }
protected virtual void OnGoBackRequested(object sender, DeviceGestureEventArgs e) { if (!e.Handled) { if (NavigationService.CanGoBack()) { NavigationService.GoBack(); e.Handled = true; } } }
protected virtual void OnHardwareButtonsBackPressed(object sender, BackPressedEventArgs e) { if (NavigationService.CanGoBack()) { NavigationService.GoBack(); e.Handled = true; } else { this.Exit(); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnGoBackRequested(object sender, DeviceGestureEventArgs e) { if (NavigationService.CanGoBack()) { NavigationService.GoBack(); e.Handled = true; } else if (DeviceGestureService.IsHardwareBackButtonPresent && e.IsHardwareButton) { Exit(); } }
/// <summary> /// Handle hardware back button by navigating back if possible using the NavigationService /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void HardwareButtonsOnBackPressed(object sender, BackPressedEventArgs e) { if (NavigationService.CanGoBack()) { NavigationService.GoBack(); e.Handled = true; } else { Exit(); } }
private async Task AddStation(Station station) { await StationService.AddStationAsync(station); if (NavigationService.CanGoBack()) { NavigationService.GoBack(); } else { NavigationService.NavigateToMainPage(); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); ThemeService.FirstRun(); SetContentView(Resource.Layout.activity_main); this.WireUpControls(); this.SetToolbarWithDrawer(Toolbar, Drawer, 0, 0); Ioc.Resolve <PermissionsService>().SetActivity(this); Ioc.Resolve <FileService>().SetActivity(this); NavigationService = Ioc.Resolve <NavigationService>() .SetFragmentManager(SupportFragmentManager) .SetFragmentContainerId(Resource.Id.FragmentContainerView); GestureService = Ioc.Resolve <GestureService>(); this.WhenActivated((CompositeDisposable disposable) => { Observable.FromEventPattern <GestureEventArgs>( h => GestureService.GoBackRequested += h, h => GestureService.GoBackRequested -= h) .Subscribe(x => { if (!x.EventArgs.Handled && NavigationService.CanGoBack()) { NavigationService.GoBack(); x.EventArgs.Handled = true; } }) .DisposeWith(disposable); Ioc.Resolve <IShellEvents>() .WhenTitleSet() .Throttle(TimeSpan.FromMilliseconds(150)) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(title => Toolbar.Title = title) .DisposeWith(disposable); Disposable .Create(() => { }) .DisposeWith(disposable); }); NavigationService.NavigateTo(PageKeys.HomePage); }
private async Task DeleteStation() { string name = CurrentStation.Name; await StationService.DeleteStationAsync(name); if (NavigationService.CanGoBack()) { NavigationService.GoBack(); } else { NavigationService.NavigateToMainPage(); } }
public void SetupBackButton() { SettingsService settings = SettingsService.Instance; if (settings.UseHeaderBackButton) { ShellView.IsBackButtonVisible = NavigationViewBackButtonVisible.Collapsed; _navManager.AppViewBackButtonVisibility = NavigationService.CanGoBack() ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed; } else { _navManager.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; ShellView.IsBackButtonVisible = NavigationViewBackButtonVisible.Auto; ShellView.IsBackEnabled = NavigationService.CanGoBack(); } }
/// <summary> /// Permet de revenir en arriére /// Cette fonction n'est utile que pour la version WINDOWS_APP puisque la version WINDOWS_PHONE_APP utilise le backbutton avec l'implémentation livré dans Navegar /// ou bien une surcharge de cette implémentation (voir l'exemple dans le fichier App.xaml.cs) /// </summary> private void Cancel() { if (NavigationService.CanGoBack()) { //Lorsque l'on revient d'une commande on rafraichi la liste des commandes sur la page de liste if (NavigationService.GetTypeViewModelToBack() == typeof(ListCommandesPageViewModel)) { //Permet de relancer la fonction LoadDatas aprés la navigation arriére vers la liste des commandes NavigationService.GoBack("LoadDatas", new object[] {}); } else { NavigationService.GoBack(); } } }
public ShellViewModel() { Navigation = new AppNavigation(); Navigation.LoadNavigation(); HamburguerButtonVisibility = Visibility.Visible; SetHamburguerButtonVisibility += ((sender, hamburguerButtonVisibility) => { HamburguerButtonVisibility = hamburguerButtonVisibility; }); NavigationService.NavigatedToPage += NavigationService_NavigatedToPage; SystemNavigationManager.GetForCurrentView().BackRequested += ((sender, e) => { if (NavigationService.CanGoBack()) { e.Handled = true; NavigationService.GoBack(); } }); }
/// <summary> /// Ovveride with logic as to what happens when <see cref="IGestureService.GoBackRequested"/> is fired, /// by default it will try to close all drawers if they are closed then it will /// call <see cref="INavigationService.GoBack()"/> if its possible. /// </summary> protected virtual void OnGoBackRequested(object sender, GestureEventArgs e) { if (e.Handled) { return; } if (Drawer != null && (Drawer.IsDrawerOpen(GravityCompat.Start) || Drawer.IsDrawerOpen(GravityCompat.End))) { Drawer.CloseDrawers(); e.Handled = true; } else if (NavigationService != null && NavigationService.CanGoBack()) { NavigationService.GoBack(); e.Handled = true; } else { e.Handled = false; } }
public ShellPage() { InitializeComponent(); this.DataContext = this; ShellPage.Current = this; this.SizeChanged += OnSizeChanged; if (SystemNavigationManager.GetForCurrentView() != null) { SystemNavigationManager.GetForCurrentView().BackRequested += ((sender, e) => { if (SupportFullScreen && ShellControl.IsFullScreen) { e.Handled = true; ShellControl.ExitFullScreen(); } else if (NavigationService.CanGoBack()) { NavigationService.GoBack(); e.Handled = true; } }); NavigationService.Navigated += ((sender, e) => { if (NavigationService.CanGoBack()) { SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; } else { SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; } }); } }
public Shell(Frame rootFrame) { InitializeComponent(); Presenter.Content = rootFrame; NavigationService = Ioc.Resolve <NavigationService>(); this.WhenActivated(disposable => { Ioc.Resolve <IShellEvents>() .WhenTitleSet() .Throttle(TimeSpan.FromMilliseconds(150)) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(title => NavigationView.Header = title) .DisposeWith(disposable); Observable.FromEventPattern <NavigationEventArgs>( h => NavigationService.Navigated += h, h => NavigationService.Navigated -= h) .Subscribe(e => { NavigationView.IsBackEnabled = NavigationService.CanGoBack(); }) .DisposeWith(disposable); Observable.FromEventPattern <TypedEventHandler <MUXC.NavigationView, MUXC.NavigationViewBackRequestedEventArgs>, MUXC.NavigationViewBackRequestedEventArgs>( h => NavigationView.BackRequested += h, h => NavigationView.BackRequested -= h) .Subscribe(e => { NavigationService.GoBack(); }) .DisposeWith(disposable); }); }
public ShellPage() { InitializeComponent(); _navManager = SystemNavigationManager.GetForCurrentView(); _settingsNavigationStr = "SettingPage?PivotItem=0"; string title = Windows.ApplicationModel.Package.Current.DisplayName; // determine and set if the app is started in debug mode Title = System.Diagnostics.Debugger.IsAttached ? "[Debug] " + title : title; // Hide default title bar. CoreApplicationViewTitleBar coreTitleBar = CoreApplication.GetCurrentView().TitleBar; coreTitleBar.IsVisibleChanged += CoreTitleBar_IsVisibleChanged; SetTitleBarAsDraggable(); // Register a handler for when the size of the overlaid caption control changes. // For example, when the app moves to a screen with a different DPI. coreTitleBar.LayoutMetricsChanged += CoreTitleBar_LayoutMetricsChanged; if (WindowDisplayInfo.GetForCurrentView() == WindowDisplayMode.FullScreenTabletMode) { AppTitleBar.Visibility = Visibility.Collapsed; } ShellViewInternal = ShellView; ShellView.Content = _frame = new Frame(); NavigationService = NavigationFactory.Create(_frame).AttachGestures(Window.Current, Gesture.Back, Gesture.Forward, Gesture.Refresh); SetupGestures(); SetupBackButton(); NavigationService.CanGoBackChanged += (s, args) => { //Backbutton setting if (SettingsService.Instance.UseHeaderBackButton) { _navManager.AppViewBackButtonVisibility = NavigationService.CanGoBack() ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed; } else { if (ShellView.IsBackEnabled != NavigationService.CanGoBack()) { ShellView.IsBackEnabled = NavigationService.CanGoBack(); if (ShellView.IsBackButtonVisible == NavigationViewBackButtonVisible.Collapsed) { ShellView.IsBackButtonVisible = NavigationViewBackButtonVisible.Auto; } } } }; _frame.Navigated += (s, e) => { if (TryFindItem(e.SourcePageType, e.Parameter, out object item)) { SetSelectedItem(item, false); // TODO test if nessasary if (item == null) { return; } } }; ShellView.ItemInvoked += (sender, args) => { SelectedItem = args.IsSettingsInvoked ? ShellView.SettingsItem : Find(args.InvokedItemContainer as NavigationViewItem); }; if (System.Diagnostics.Debugger.IsAttached) { Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().IsScreenCaptureEnabled = true; } else { //prevent screenshot capture for the app Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().IsScreenCaptureEnabled = false; } Loaded += ShellPage_Loaded; }
/// <summary> /// Permet de vérifier que l'on peut revenir en arriére /// </summary> /// <returns></returns> private bool CanCancel() { return(NavigationService.CanGoBack()); }