You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clickable Interactive control sample for custom titlebar (#1360)
With 1.4 changes, WinUI 3 custom titlebar now uses appwindow titlebar + nonclientinputpointersource apis under the hood. This opens up new possibilities like allowing clickable interactive controls like textbox, button in the titlebar area, surrounded by draggable region on both left and the right sides.
This code adds a sample to titlebar page which shows users how to create interactive controls in winui 3 titlebar. It also demonstrates the power of mixing and matching high level winui 3 custom titlebar apis and low level nonclient apis.
WinUI provides a default titlebar in such cases where the user doesn't explicitly provide a uielement, for setting the titlebar. The system titlebar (Windows-provided titlebar) disappears and client area content is extended to non client area.
35
+
In this default case, entire non client region (titlebar region) get system titlebar behaviors like drag regions, system menu on context click etc.
36
+
<LineBreak></LineBreak>
37
+
This is the recommended way of using TitleBar apis and covers most common scenarios.
38
+
<LineBreak></LineBreak>
39
+
It can be applied by just calling ExtendsContentIntoTitleBar api. This internally calls SetTitleBar api with null argument and provides the default case.
40
+
<LineBreak></LineBreak>
41
+
Use the button below to toggle between system titlebar and default custom titlebar.
User can set a top-level UIElement (defined as appTitleBar here) as titlebar for the window. The system titlebar disappears and the chosen uielement starts acting like the titlebar. <LineBreak></LineBreak>
54
+
For finer controls, a user can set a top-level UIElement (defined as appTitleBar here) as titlebar for the window. The system titlebar disappears and the chosen uielement starts acting like the titlebar (gets all system titlebar behavior). <LineBreak></LineBreak>
35
55
The Background and Foreground Color dropdowns set the foreground and background of titlebar and caption buttons respectively.
56
+
<LineBreak></LineBreak>
57
+
Use the button below to toggle between system titlebar and custom WinUI titlebar.
WinUI provides a fallback titlebar in case where user doesn't want to provide a uielement for setting the titlebar.
120
-
A small horizontal section next to min/max/close caption buttons is chosen as the fallback titlebar.
121
-
<LineBreak></LineBreak>
122
-
It can be applied by just calling ExtendsContentIntoTitleBar api only and not calling SetTitleBar afterwards. It can also be manually triggered by calling SetTitleBar api with null arument.
142
+
WinUI custom titlebar now hosting interactive clickable controls within non client region of the window, when using custom titlebar.
123
143
<LineBreak></LineBreak>
124
-
Use the Color dropdown controls in the section above to change color of the fallback titlebar.
WinUI allows <Bold> mix and match </Bold> of higher level WinUI custom titlebar apis with lower level AppWindow and NonClientInputPointerSource apis for most cases.
153
+
One exception is one should not use <Italic> Window.SetTitlebar </Italic> api along with any lower level api which also sets drag regions as it can result in unexpected behavior.
154
+
If needed, set <Italic> Window.SetTitlebar </Italic> to null (default case) and proceed to use lower level apis for drag functionality.
155
+
<LineBreak></LineBreak>
156
+
Use the button below to toggle between system titlebar and default custom titlebar.
"Description": "This sample shows how to use a custom UIElement as titlebar for app's window.",
2831
+
"Description": "This sample shows how to use a custom titlebar for the app's window. There are 2 ways of doing it: using default titlebar and setting an UIElement as a custom titlebar.",
2832
2832
"Content": "<p>Look at the <i>TitleBarPage.xaml</i> file in Visual Studio to see the full code for this page.</p>",
0 commit comments