简体   繁体   中英

Disable back button in prism.windows 6.3 for UWP App

I try disabling the soft back button in a desktop UWP App using prism, but the button always shows up after navigation using NavigationService of Prism.

How to disable the back button completely or (if not possible) on page base?

I tried this on a autowired view model:

    public override void OnNavigatedTo(NavigatedToEventArgs e, Dictionary<string, object> viewModelState)
    {
        base.OnNavigatedTo(e, viewModelState);
        SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
    }

Disable back button in prism.windows 6.3 for UWP App

If you want to disable back button, you could use DeviceGestureService to realize it. You could overwrite OnCreateDeviceGestureService method to get GestureService instance, and set UseTitleBarBackButton to be false like following.

protected override IDeviceGestureService OnCreateDeviceGestureService()
{
    var svc = base.OnCreateDeviceGestureService();
    svc.UseTitleBarBackButton = false;
    return svc;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM