microsoft / WindowsAppSDK

The Windows App SDK empowers all Windows desktop apps with modern Windows UI, APIs, and platform features, including back-compat support, shipped via NuGet.
https://docs.microsoft.com/windows/apps/windows-app-sdk/
MIT License
3.78k stars 319 forks source link

Implement SystemNavigationManager in Winui3 #2398

Open cesarchefinho opened 2 years ago

cesarchefinho commented 2 years ago

By implementing SystemNavigationManager in winui we will get hardware back button on desktop applications and for keyboards/mouse with back button and we Wil get parity with Uno that implement this class in Android and iOS and Linux and TVs. Also we will get back button support for windows 11 on tablets that have back button too.

Today th Winui3 in an Uno solution don't have SystemNavigationManager in windows project but the other projects in this solution have SystemNavigationManager (Android, IOS, wasm, etc) , Uno team says that this is out of scope of uno because Winui3 windows project haven't any Uno files.

Also this will Improve and facilitate the process of porting uwp legacy code that uses SystemNavigationManager to WInui3

Proposal: [your title here]

Summary

Rationale

Scope

Capability Priority
This proposal will allow developers to accomplish W Must
This proposal will allow end users to accomplish X Should
This proposal will allow developers to accomplish Y Could
This proposal will allow end users to accomplish Z Won't

Important Notes

Open Questions

BenJKuhn commented 2 years ago

@ujjwalchadha is looking at UWP migration issues, and is aware of this particular gap. Tagging him to make sure that he's aware of the opportunities and challenges that you've identified.

jeanplevesque commented 11 months ago

Any update on this? I'm facing the same challenges.

mnxamdev commented 2 months ago

@codendone what does it mean if the "feature" label has been removed? If it isn't going to be developed can you or anyone at Microsoft recommend a work around for this code we have in our app to programmatically enable the back button?

var nm = SystemNavigationManager.GetForCurrentView();

if(nm!= null)
{
    nm.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
}
codendone commented 2 months ago

@mnxamdev The removal of the "feature" label was just to consolidate only a "feature proposal" label. Having both was confusing.

WinUI3 apps don't automatically have a back button. You can manually create one, possibly extending nito the titlebar to put the back button up there, similar to what WinUI 3 Gallery does. The new TitleBar control being worked on, which you can try in the recent 1.6-experimental1 release, has an optional back button which will make this easier.

mnxamdev commented 2 months ago

@mnxamdev The removal of the "feature" label was just to consolidate only a "feature proposal" label. Having both was confusing.

WinUI3 apps don't automatically have a back button. You can manually create one, possibly extending nito the titlebar to put the back button up there, similar to what WinUI 3 Gallery does. The new TitleBar control being worked on, which you can try in the recent 1.6-experimental1 release, has an optional back button which will make this easier.

Thanks for the reply @codendone. I'm actually using MAUI which forces us to use WinUI3 so I don't think I'll be able to use experimental features. Also, we're looking to release ASAP and probably not ok with using experimental features that aren't stable yet.

Any other ideas on a work around? I tried something where I traverse the visual stack and get to the NavigationView to set the back button visibility and enable it but while it shows it's not clickable unfortunately.

var nv = GetNavigationView();

if(nv != null)
{
    nv.IsBackEnabled = true;
    nv.IsBackButtonVisible = NavigationViewBackButtonVisible.Visible;
}