-
Notifications
You must be signed in to change notification settings - Fork 693
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
WinUI TitleBar API Spec #10056
WinUI TitleBar API Spec #10056
Conversation
Are the following modes considered?
|
Yes, this is an inherent and logical result of the whole ExtendsContentIntoTitleBar concept. You're telling the app/window to hide its actual title bar. If you want a control (like this) to be used as a window's title bar, from an app's perspective, this raises the bigger question of "Is this control part of the window's content or not?" If we could set the window's title bar properties in the following manner, then the ExtendsContentIntoTitleBar part will become unneeded. Just make sure the background of the title bar is transparent so that it show the window background. Think of it like this: <Window
x:Class="App1.MainWindow"
xmlns:local="using:App1"
mc:Ignorable="d">
<TitleBar x:Name="DefaultTitleBar" Title="Default TitleBar" Subtitle="Preview">
<TitleBar.IconSource>
<SymbolIconSource Symbol="Home"/>
</TitleBar.IconSource>
</TitleBar>
<!-- App content - in the 100% correct term -->
</Window> |
- Custom Height - 32px as default / 48px if content != null | ||
![TitleBar Size Variants](images/titlebar-sizevariant.png) | ||
|
||
## Considerations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The WinUI title bar should meet Windows app design guidelines (see #9907). For example:
A single-click/tap on the icon should show system window menu.
A double-click/tap should close the window.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great callout. I will make sure it is included in the Considerations section.
|
This took my UK brain a moment to decipher lol |
Correct :) |
public class TitleBar : Control | ||
``` | ||
|
||
## TitleBar.Header property |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised nobody has brought this up, after the heated discussions in #9700.
Header and Footer, while being concise terms, can be confusing in this context of a horizontal layout. Other terminology could be:
- Start and End (e.g. Windows.UI.Xaml.TextAlignment.Start/End
TextAlignment - Before and After (e.g. CSS, Fluent Web UI)
- Leading and Trailing (e.g. Apple SwiftUI Toolbar)
In the end, it will be hard to objectively decide on what's best. Personally, I prefer StartElement and EndElement here. Before and After imply the center of the title bar would have the actual content, while in most apps the center of the title bar is actually empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the thought, but don't agree. A head is not a synonym for the top but for the leading part. Animals that are "built horizontally" have their head at the front, not on top.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm with Whiskhub here. Header/Footer is misleading. The only argument I see for keeping the naming is that TabView also got this wrong, but I'd rather you don't continue down the confusing naming and address it here with better names, like Leading
and Trailing
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm for header/footer if they're not going to change it everywhere else at the same time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per the original feedback thread, agree and prefer Before/After #9700 (comment)
I hope there will be some sample, guidance, or official support for apps which use tabbed navigation within the titlebar area. |
## TitleBarTemplateSettings Class | ||
<!-- TODO --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see information on this class. I had pointed out in #9700 that this was an odd way to set the icon here, rather than just setting the icon directly on the window or titlebar instance. It feels a bit like this is just internal plumbing that is bubbling up into the public API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TitleBarTemplateSettings class would not be used to set the Icon Property. It was added originally to implement interactive / non-interactive regions in the TitleBar. I will most likely be removing it, as it is no longer needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I misspoke in my previous comment. The Icon in TitleBar will continue to be applied through TitleBarTemplateSettings.IconElement. By best practice, we should not be modifying xaml elements in codebehind, should the element be removed in re-templating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This confuses me. Normally templatesettings classes are used to simplify binding things into the template, and not as the main way to set a property (which would also make it harder to set from xaml). Reference: https://learn.microsoft.com/en-us/windows/uwp/xaml-platform/template-settings-classes#the-scenario-for-templatesettings-classes
Today is November 12! 😐 |
The feedback period is up! Thank you all very much for your contributions thus far. I will be closing this PR while we parse through the feedback. Updates to the spec will still be done on this branch, and I will re-open the PR when it is ready for final review and merge. Closing this PR is simply to indicate that we are no longer actively gathering feedback. |
public class TitleBar : Control | ||
``` | ||
|
||
## TitleBar.Header property |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per the original feedback thread, agree and prefer Before/After #9700 (comment)
Gets or sets the TitleBar's icon. | ||
|
||
```cs | ||
public IconSource IconSource { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it clear who owns the underlying icon handle here, to avoid common handle leaks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't see any talk about wiring this up to Window.Titlebar
.
## TitleBar.IconSource property | ||
|
||
Gets or sets the TitleBar's icon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this going to be wired up to WM_SETICON
for the notification area? (If so, I have a laundry list of things you need to keep in mind...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great callout. Please do share the list of considerations here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some considerations include:
-
Ownership and lifetime of icon handles: You'll need to decide whether the developer is responsible for managing the
HICON
handle, or if ownership is transferred to the framework. If ownership is transferred, will the framework duplicate the handle for use in multiple windows, or allow developers to set per-window icons? And don't forget about globally shared handles, which should not be freed automatically. -
Icon size variants: The API should support setting both small and big icon sizes, as both are used across different UI surfaces for visual consistency.
-
System theme and accessibility: The API should allow for setting multiple icon variants to accommodate different system themes (e.g., light/dark mode), high contrast mode, and high DPI scenarios. Again, it's all about visual consistency.
Is the v1.7experimental release the final TitleBar API? I'm a little confused that it is identical to the 1.6 one, and from my understanding it was pulled from the 1.6 release to address the design feedback? |
No, the version in 1.7-experimental is still the one from 1.6-experimental. The feedback period for collection on the spec here just closed last week; so now that'll be go into improving the control. I agree the timing here is bit off, but part of it was us shoring up the definition of the process here. I'll let @karkarl add any more specifics from a timeline/planning perspective, as I don't have up-to-date info on that, just the info above. I had called this out during the .NET Conf talk last week when we mentioned this as well. |
@michael-hawker awesome! Great to hear! |
Co-authored-by: whiskhub <[email protected]>
Co-authored-by: Jay <[email protected]>
Co-authored-by: Jay <[email protected]>
Co-authored-by: Jay <[email protected]>
Co-authored-by: Jay <[email protected]>
Co-authored-by: Jay <[email protected]>
Co-authored-by: Jay <[email protected]>
Co-authored-by: Jay <[email protected]>
Co-authored-by: Jay <[email protected]>
Co-authored-by: Jay <[email protected]>
Upon investigation, tabbed navigation in TitleBar seems to be a complete different control needing separate implementation. Hence it is considered out of scope for this TitleBar control. As for future support, I hope so as well. Active community feedback for TitleBar has helped drive prioritization for the control, so please file feature requests or start a new discussion thread! |
Alternate naming considerations for `Header`, `Content`, `Footer`: | ||
- Header and Footer aligns with TabView.TabStripHeader and TabView.TabStripFooter | ||
- Start and End (e.g. [Windows.UI.Xaml.TextAlignment](https://learn.microsoft.com/en-us/uwp/api/windows.ui.xaml?view=winrt-26100)) | ||
- Before and After (e.g. CSS, [Fluent Web UI](https://react.fluentui.dev/?path=/docs/components-input--docs#content-before-after)) | ||
- Leading and Trailing (e.g. [Apple SwiftUI Toolbar](https://developer.apple.com/documentation/swiftui/toolbaritemplacement/topbarleading)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean this is up for discussion still in this design as a todo? Or is this more of a comparison to explain what is meant by these concepts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are notes for posterity. I am submitting this spec for review and wanted to call out the comparisons.
This PR adds the dev and functional spec for WinUI TitleBar.
Community members can provide feedback by commenting directly on the PR, or through a code suggestion with Github tools.
Feedback should be constructive and specific, addressing potential use cases, design concerns, and functionality.
This PR will be open for feedback for a month: October 11th – November 11th
For more info on the public api review process: https://aka.ms/winappsdk/api-specs-review