public async Task Navigate_To_Subsequent_Page_Back_Button_Visible() { await DispatcherHelper.ExecuteOnUIThread(() => { var eventAggregator = new EventAggregator(); var frame = new FrameFacadeAdapter(new Frame(), eventAggregator); var sessionStateService = new MockSessionStateService(); sessionStateService.GetSessionStateForFrameDelegate = (currentFrame) => new Dictionary<string, object>(); var navigationService = new FrameNavigationService(frame, (pageToken) => typeof(MockPage), sessionStateService); var deviceGestureService = new DeviceGestureService(eventAggregator); deviceGestureService.UseTitleBarBackButton = true; var navigationManager = SystemNavigationManager.GetForCurrentView(); // Reset back button visibility before running, can't do this in TestInitialize because CoreWindow sometimes isn't ready SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; Assert.AreEqual(AppViewBackButtonVisibility.Collapsed, navigationManager.AppViewBackButtonVisibility); navigationService.Navigate("Mock", 1); Assert.AreEqual(AppViewBackButtonVisibility.Collapsed, navigationManager.AppViewBackButtonVisibility); navigationService.Navigate("Mock", 2); Assert.AreEqual(AppViewBackButtonVisibility.Visible, navigationManager.AppViewBackButtonVisibility); }); }
/// <summary> /// Creates the device gesture service. /// </summary> /// <returns>The initialized device gesture service.</returns> private IDeviceGestureService CreateDeviceGestureService() { var deviceGestureService = OnCreateDeviceGestureService(); if (deviceGestureService == null) { deviceGestureService = new DeviceGestureService(EventAggregator); deviceGestureService.UseTitleBarBackButton = true; } return deviceGestureService; }
/// <summary> /// /// </summary> /// <returns></returns> protected virtual IDeviceGestureService CreateDeviceGestureService() { DeviceGestureService deviceGestureService = new DeviceGestureService(); deviceGestureService.UseTitleBarBackButton = true; return deviceGestureService; }
public async Task Navigate_To_Page_With_UseTitleBarBackButton_False_Does_Not_Change_Back_Button_Visibility() { await DispatcherHelper.ExecuteOnUIThread(() => { var eventAggregator = new EventAggregator(); var frame = new FrameFacadeAdapter(new Frame()); var sessionStateService = new MockSessionStateService(); sessionStateService.GetSessionStateForFrameDelegate = (currentFrame) => new Dictionary<string, object>(); var navigationService = new FrameNavigationService(frame, (pageToken) => typeof(MockPage), sessionStateService); var deviceGestureService = new DeviceGestureService(); deviceGestureService.EnableTitleBarBackButton(eventAggregator); var navigationManager = SystemNavigationManager.GetForCurrentView(); // Reset back button visibility before running, can't do this in TestInitialize because CoreWindow sometimes isn't ready SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; // If it's collapsed and we navigate, it stays collapsed Assert.AreEqual(AppViewBackButtonVisibility.Collapsed, navigationManager.AppViewBackButtonVisibility); navigationService.Navigate("Mock", 1); Assert.AreEqual(AppViewBackButtonVisibility.Collapsed, navigationManager.AppViewBackButtonVisibility); // If it's visible and our back stack is emptied, it stays visible navigationManager.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; navigationService.ClearHistory(); Assert.AreEqual(AppViewBackButtonVisibility.Visible, navigationManager.AppViewBackButtonVisibility); }); }