microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.27k stars 674 forks source link

Proposal: A common titlebar control for UWP and Win32 apps #6111

Open martibravo opened 2 years ago

martibravo commented 2 years ago

Proposal: A common TitleBar control for WinUI 3.

In both WinUI2 and 3, the titlebar, albeit different ones, are outdated. I am not saying they should be replaced. But many developers would like a default control for a custom titlebar, following the design of Windows 11's Calculator and Paint apps. image

The control would basically be a element with an Icon and a Title, because the window caption buttons are already painted over by the system.

Only for WinUI3 apps: right clicking on the control would show a modern Context Menu (MenuFlyout) with the regular options "Close, Minimize, Maximize/Restore, Move, Size".

Summary

Provide a control named "Microsoft.UI.Xaml.Controls.ModernTitlebar" or "CommonTitlebar" or simply "CustomTitlebar" that can be placed inside the app when ExtendContentsIntoTitleBar is set to true.

Rationale

Scope

Capability Priority
Set a common titlebar for all WinUI apps Must
Show an app icon's and title in the style of W11's Calculator Must
Use a modern MenuFlyout to show default options Should
Have a method to add custom entries to the titlebar's context menu Could
Have a method to add buttons before the app icon (like a back button) Should
Be the default titlebar Won't
JaiganeshKumaran commented 2 years ago

In my opinion there's no need for a separate opt-in cont. Instead for WinUI 3, by default a modern one should be used when not extended. All the functionality mentioned in this proposal such as adding buttons like the back button, hiding/showing app icon can be built-in to the Window class and affect the default title bar.

mdtauk commented 2 years ago

Ideally placing a TitleBar control onto your app's window, would automatically handle the extending of the app's content into the title bar area, the re-colouring of the window controls etc.

In fact, the Window XAML could have a property you populate with a control, so the code is handled for the developers. And default templates could include it.

JaiganeshKumaran commented 2 years ago

Ideally placing a TitleBar control onto your app's window, would automatically handle the extending of the app's content into the title bar area, the re-colouring of the window controls etc.

In fact, the Window XAML could have a property you populate with a control, so the code is handled for the developers. And default templates could include it.

I don't think that's necessary as the title bar will differ if you use NavigationView compared to using something like a tab view, so instead of that creating a custom title bar could be made much easier rather than an entire control that has limited customizability options. These will help more apps, not just ones which follow the standard patterns.

Few things that app developers need to do currently for the best experience:

I'm not a big fan of having complete pre-build solutions for everything with limited customization without delving deep (like retemplating it).

michael-hawker commented 2 years ago

FYI @niels9001