Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Why is TitleBar customisation not coming to Win32 WinUI 3 Windows? #2124

Closed
mdtauk opened this issue Mar 17, 2020 · 20 comments
Closed
Labels
area-TitleBar Issues related to custom window title bars. product-winui3 WinUI 3 issues question team-CompInput Issue for IXP (Composition, Input) team

Comments

@mdtauk
Copy link
Contributor

mdtauk commented Mar 17, 2020

Regarding the API Spec being proposed here Window_and_Application_API_Spec.md.
Could you provide some information as to why the ability to customise or replace the TitleBar and Window Controls is not being ported/enabled for Win32 created Windows? I understand this is part of the CoreWindow which is reserved for UWP applications, but Win32 should typically be a superset of UWP features, but with more customisation.

I realise there is a way to access the Hwnd underlying for the window, but it could be beneficial to wrap up some of this ability in a simple to use API, accessible from XAML and code - which does not require such deep access to window drawing - in a way that enables the same scenarios that CoreWindow enables.

https://github.com/thomasclaudiushuber/microsoft-ui-xaml-specs/blob/patch-1/active/Win32/Window_and_Application_API_Spec.md#windowsettitlebaruielement-method

Visual examples:

image
image
image

with NavigationView Extended into TitleBar area


image

image

customised but not Extended into TitleBar area


image

image

without extending into TitleBar

@msft-github-bot msft-github-bot added the needs-triage Issue needs to be triaged by the area owners label Mar 17, 2020
@Felix-Dev
Copy link
Contributor

Felix-Dev commented Mar 17, 2020

There are other proposed APIs proposed that will be part of the future phases.

Titlebar customization might be part of the future APIs. If I recall correctly, the team stated that it is having in mind the UWP-style titlebar customization APIs for future WinUI support: #1323 (comment)

That might or might not mean support for WinUI desktop.

I asked a similar question in the spec: microsoft/microsoft-ui-xaml-specs#71 (comment)

@mdtauk
Copy link
Contributor Author

mdtauk commented Mar 17, 2020

Then the questions are:
Will the TitleBar API come in the future?
Will it be there for WinUI 3.0 release?
If its not coming, why was that decision made?
Will there be code guidence to achieve the same effect of colourising the window controls, extending Acrylic into the titlebar area, and using custom Xaml elements as the grabbable title area - using HWND access.

@ranjeshj
Copy link
Contributor

@marb2000 @YuliKl as FYI

@ranjeshj ranjeshj removed the needs-triage Issue needs to be triaged by the area owners label Mar 17, 2020
@shaheedmalik
Copy link

I wish they wouldn't bring the customizations over in order to keep the title bar consistent. It isn't consistent even in UWP apps.

@mdtauk
Copy link
Contributor Author

mdtauk commented Mar 17, 2020

I wish they wouldn't bring the customizations over in order to keep the title bar consistent. It isn't consistent even in UWP apps.

By default, the app window gives you the typical TitleBar you would see with Win32 mostly. But many apps use the NavigationView, and that does not look good when it does not extend into the TitleBar.

UWP makes it easy to achieve this, but WInUI Desktop (as of the current spec) will not have a way to achieve this.

image
image
image

with NavigationView Extended into TitleBar area


image

image

customised but not Extended into TitleBar area


image

image

without extending into TitleBar

@shaheedmalik
Copy link

With all of those apps, the title bar behavior isn't consistent when you put them in Tablet Mode.

@mdtauk
Copy link
Contributor Author

mdtauk commented Mar 17, 2020

With all of those apps, the title bar behavior isn't consistent when you put them in Tablet Mode.

Tablet Mode "should" autohide the Window Controls/TitleBar - This is to have a full-screen experience. I would expect the same behaviour for all WinUI apps, UWP or Win32.

@shaheedmalik
Copy link

It should but isn't consistent. See Microsoft Store, People app, Photos, and Feedback Hub.

In regards to Win32, I figure that has a lot to do with Sets returning. Programs such as Word were great offenders, obstacles in the way of that initiative.

@mdtauk
Copy link
Contributor Author

mdtauk commented Mar 17, 2020

It should but isn't consistent. See Microsoft Store, People app, Photos, and Feedback Hub.

In regards to Win32, I figure that has a lot to do with Sets returning. Programs such as Word were great offenders, obstacles in the way of that initiative.

Different apps will have different needs. You will never get 100% rigid consistency with TitleBars, but there will be a disparity between UWP app capabilities and WinUI Desktop apps - unless there is sample code for achieving the same effects with HWND interfaces - or these capabilities are introduced.

WPF Windows have options for transparency and titlebar displays - so you should expect WinUI Desktop apps to be capable of matching both UWP behaviours, WPF behaviours, as well as traditional Win32 window behaviours.

@mveril
Copy link

mveril commented May 23, 2020

I wrote an issue for that in microsoft/WindowsAppSDK#49 Project Reunion should be the good place for this issue I think

@MikeHillberg
Copy link
Contributor

The technical difficulty with this in WinUI3 is enabling a custom title bar that the user can still drag and double-click on. This is enabled in WinUI2 with Window.SetTitleBar, which registers with the shell the system (WinUI2) Visual behind the specified element. But with WinUI3 we need a new mechanism because we don't currently have a system Visual there.

@MikeHillberg MikeHillberg added the team-CompInput Issue for IXP (Composition, Input) team label May 26, 2020
@mdtauk
Copy link
Contributor Author

mdtauk commented May 26, 2020

Could WinUI / Reunion include a TitleBar xaml control, with built in behaviours and the ability to re-colour and theme/re-template?

@jarno9981
Copy link

@MikeHillberg when will titlebar costimizing come to winui3 is very help full feature

@Wufus
Copy link

Wufus commented Sep 10, 2021

We have a problem with using xBind converters in MainWindow.xaml - they are not working. #4966 pushes to use UI in another file. This make united title and UI impossible.

@knightmeister
Copy link

I'm curious what the state of this issue is. Today, in Win UI 3 it's possible to set a custom titlebar and extend the view into the titlebar area.

There are, however a lot of issues I've seen; I am unable to get any elements in the title bar to respond to click events in the same way they did with UWP, and if you set a background it paints over the min/max/close boxes.

From my (uninformed) perspective, the most obvious thing to do for the system when setting a custom titlebar would be to paint the system min/max/close boxes over the top of the element that is set as the titlebar. This would then allow things like a custom background to be set.

I really like the idea @mdtauk raised above about having a custom TitleBar xaml control. Another possibility would be to make a templated property (not sure if this is the right term) on the window.

@LeonBlade
Copy link

I'm curious what the state of this issue is. Today, in Win UI 3 it's possible to set a custom titlebar and extend the view into the titlebar area.

There are, however a lot of issues I've seen; I am unable to get any elements in the title bar to respond to click events in the same way they did with UWP, and if you set a background it paints over the min/max/close boxes.

From my (uninformed) perspective, the most obvious thing to do for the system when setting a custom titlebar would be to paint the system min/max/close boxes over the top of the element that is set as the titlebar. This would then allow things like a custom background to be set.

I really like the idea @mdtauk raised above about having a custom TitleBar xaml control. Another possibility would be to make a templated property (not sure if this is the right term) on the window.

I'm experiencing a similar issue on my end while exploring WinUI 3 for the first time. I'm having to recreate the TitleBar entirely in order to achieve the same thing that you could use CoreApplication for on UWP for example. It also (seemingly) means I have to implement drag and drop again for titlebar if you extend it the entire width of the window?

Perhaps my ignorance here is causing my issues. There aren't many resources on WinUI 3 from developers at large so I can better understand certain practices. I'm not creating a UWP app, so this also causes issues.

@tuggernuts
Copy link

@knightmeister not sure if this helps at all, but this doc explains how to properly set colors in custom title bar. Apologies if this isn't your issue.

Also in agreement that for custom title bars to have any purpose, we should be able to customize them. That means controls that can exist in that space, i.e. sliding NavigationView into that area, or the occasional button, searchbox, etc. I tend not to like to put anything in the bar, except the aforementioned NavView as @mdtauk points out.

@knightmeister
Copy link

Hi @tuggernuts, cheers yes I have seen that doc. Getting this all working is very nuanced and would be great if it could be slightly less so.

@Xyncgas
Copy link

Xyncgas commented Feb 4, 2022

I just simply wanting to color the title bar so it fits my app themes

@krschau krschau added product-winui3 WinUI 3 issues area-TitleBar Issues related to custom window title bars. labels Jun 21, 2022
@pratikone
Copy link
Contributor

pratikone commented Jun 22, 2022

You can now customize the titlebar of a WinUI app by setting your own UI Element as a custom titlebar. The background of of the titlebar can be set by defining resource keys here https://docs.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.window.settitlebar?view=windows-app-sdk-1.1#colors. You can also set WindowCaptionBackground as Transparent and just set background of your uielement which is set as titlebar. It will provide a color to your titlebar area

Hopefully this helps. I am closing this issue. Feel free to open it if it doesn't work.

@krschau krschau closed this as completed Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-TitleBar Issues related to custom window title bars. product-winui3 WinUI 3 issues question team-CompInput Issue for IXP (Composition, Input) team
Projects
None yet
Development

No branches or pull requests