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
Copy file name to clipboardExpand all lines: hub/apps/develop/title-bar.md
+57-52Lines changed: 57 additions & 52 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
description: Customize the title bar of a desktop app to match the personality of the app.
3
3
title: Title bar customization
4
4
template: detail.hbs
5
-
ms.date: 06/15/2022
5
+
ms.date: 05/27/2023
6
6
ms.topic: article
7
7
keywords: windows 10, uwp, title bar
8
8
doc-status: Draft
@@ -51,16 +51,16 @@ The exact features of the title bar and the options available to customize it de
51
51
Windowing functionality in the [Windows App SDK](./index.md) is through the [Microsoft.UI.Windowing.AppWindow](/windows/windows-app-sdk/api/winrt/microsoft.ui.windowing.appwindow) class, which is based on the Win32 HWND model. There's a 1:1 mapping between an AppWindow and a top-level HWND in your app. AppWindow and its related classes provide APIs that let you manage many aspects of your app's top-level windows, including customization of the title bar. You can modify the default title bar that Windows provides so that it blends with the rest of your UI, or extend your app canvas into the title bar area and provide your own title bar content.
52
52
53
53
> [!IMPORTANT]
54
-
> Support for title bar customization APIs varies across different versions of Windows and different versions of Windows App SDK. This table describes the details.
55
-
>
56
-
> | Customization option | Windows 10 | Windows 11 |
57
-
> | - | - | - |
58
-
> | Simple customization | Partially, since Windows App SDK 1.2 (Color customization is not supported) | Yes, all versions of Windows App SDK |
59
-
> | Full customization | Yes, since Windows App SDK 1.2 | Yes, all versions of Windows App SDK |
60
-
>
61
-
> For information on which APIs are supported on Windows 10 since Windows App SDK 1.2, refer to the [Windows App SDK Release Notes](/windows/apps/windows-app-sdk/stable-channel#version-12-stable) page under "Windowing" section for details.
62
-
>
63
-
> We recommend that you check [AppWindowTitleBar.IsCustomizationSupported](/windows/windows-app-sdk/api/winrt/microsoft.ui.windowing.appwindowtitlebar.iscustomizationsupported) in your code before you call these APIs to ensure your app doesn't crash on other versions of Windows.
54
+
> Support for title bar customization APIs varies across different versions of Windows and different versions of Windows App SDK. This table describes the details.
55
+
>
56
+
> | Customization option | Windows 10 | Windows 11 |
57
+
> | - | - | - |
58
+
> | Simple customization | Partially, since Windows App SDK 1.2 (Color customization is not supported) | Yes, all versions of Windows App SDK |
59
+
> | Full customization | Yes, since Windows App SDK 1.2 | Yes, all versions of Windows App SDK |
60
+
>
61
+
> For information on which APIs are supported on Windows 10 since Windows App SDK 1.2, refer to the [Windows App SDK Release Notes](/windows/apps/windows-app-sdk/stable-channel#version-12-stable) page under "Windowing" section for details.
62
+
>
63
+
> We recommend that you check [AppWindowTitleBar.IsCustomizationSupported](/windows/windows-app-sdk/api/winrt/microsoft.ui.windowing.appwindowtitlebar.iscustomizationsupported) in your code before you call these APIs to ensure your app doesn't crash on other versions of Windows.
64
64
65
65
For XAML apps that use WinUI 3, XAML Window APIs provide a simpler way to customize the title bar that also works on Windows 10. These APIs can be used in conjunction with the Windows App SDK APIs (see the WinUI 3 tab).
66
66
@@ -77,13 +77,13 @@ You can use AppWindow APIs with any UI framework that the Windows App SDK suppor
77
77
78
78
Windowing functionality in [WinUI 3](./index.md) is through the [Microsoft.UI.Xaml.Window](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.window) class, which is based on the Win32 HWND model. The Window class includes APIs that let you replace the standard title bar with your own custom content.
79
79
80
-
WinUI 3 is also part of the Windows App SDK, so both the Window class and the AppWindow class are available to customize the title bar. You can pass the window handle of the XAML Window to the AppWindow object and use the AppWindow functionality in conjunction with the Window APIs (see the Windows App SDK tab).
80
+
WinUI 3 is also part of the Windows App SDK, so both the Window class and the AppWindow class are available to customize the title bar. You can pass the window handle of the XAML Window to the AppWindow object and use the AppWindow functionality in conjunction with the Window APIs (see the Windows App SDK tab).
81
81
82
-
This table describes the differences between Window and AppWindow.
82
+
This table describes the differences between Window and AppWindow.
83
83
84
84
| Feature | Window class | AppWindow class |
85
85
| - | - | - |
86
-
| Windows 10 support | Yes | Partially, since Windows App SDK 1.2 (see the Windows App SDK tab). |
86
+
| Windows 10 support | Yes | Partially, since Windows App SDK 1.2 (see the Windows App SDK tab). |
87
87
| Simple customization | Title | Title, Colors, Icon and System menu |
88
88
| Replace system title bar | Window.ExtendsContentIntoTitleBar | AppWindowTitleBar.ExtendsContentIntoTitleBar |
89
89
| Set title bar content | Define your title bar in a XAML UIElement, then call SetTitleBar(UIElement). | Write custom code to calculate and set drag rectangles, including when the window size changes. |
@@ -128,7 +128,7 @@ If you want only to customize the title bar colors or icon, you can set properti
128
128
129
129
### [Windows App SDK](#tab/wasdk)
130
130
131
-
> (Partially supported on Windows 10 since Windows App SDK 1.2 and fully supported on Windows 11. See [Platform options](#platform-options) for more info.)
131
+
> (Partially supported on Windows 10 since Windows App SDK 1.2 and fully supported on Windows 11. See [Platform options](#platform-options) for more info.)
132
132
133
133
These examples show how to get an instance of [AppWindow](/windows/windows-app-sdk/api/winrt/microsoft.ui.windowing.appwindowtitlebar) and set its properties.
134
134
@@ -167,8 +167,8 @@ This example shows how to get an instance of [AppWindowTitleBar](/windows/window
167
167
privateboolSetTitleBarColors()
168
168
{
169
169
// Check to see if customization is supported.
170
-
// The method returns true on Windows 10 since Windows App SDK 1.2, and on all versions of
171
-
// Windows App SDK on Windows 11.
170
+
// The method returns true on Windows 10 since Windows App SDK 1.2, and on all versions of
> `Title` shows in the XAML IntelliSense for `Window`, but setting it in XAML causes an error. Set this property in code instead.
253
+
```xaml
254
+
<Window
255
+
...
256
+
Title="App title">
257
+
...
258
+
</Window>
259
+
```
255
260
256
261
> [!NOTE]
257
262
> To add color to the default title bar or to change the window icon that comes with a WinUI 3 window, you will need to use the Windows App SDK AppWindow APIs or opt to fully customize your titlebar.
@@ -325,7 +330,7 @@ To hide the default title bar and extend your content into the title bar area, s
325
330
326
331
### [Windows App SDK](#tab/wasdk)
327
332
328
-
> (Supported on Windows 10 since Windows App SDK 1.2 and fully supported on Windows 11. See [Platform options](#platform-options) for more info.)
333
+
> (Supported on Windows 10 since Windows App SDK 1.2 and fully supported on Windows 11. See [Platform options](#platform-options) for more info.)
329
334
330
335
This example shows how to get the [AppWindowTitleBar](/windows/windows-app-sdk/api/winrt/microsoft.ui.windowing.appwindowtitlebar) and set the [ExtendsContentIntoTitleBar](/windows/windows-app-sdk/api/winrt/microsoft.ui.windowing.appwindowtitlebar.extendscontentintotitlebar) property to `true`.
331
336
@@ -345,8 +350,8 @@ public MainWindow()
345
350
346
351
m_AppWindow=GetAppWindowForCurrentWindow();
347
352
// Check to see if customization is supported.
348
-
// The method returns true on Windows 10 since Windows App SDK 1.2, and on all versions of
349
-
// Windows App SDK on Windows 11.
353
+
// The method returns true on Windows 10 since Windows App SDK 1.2, and on all versions of
354
+
// Windows App SDK on Windows 11.
350
355
if (AppWindowTitleBar.IsCustomizationSupported())
351
356
{
352
357
vartitleBar=m_AppWindow.TitleBar;
@@ -355,8 +360,8 @@ public MainWindow()
355
360
}
356
361
else
357
362
{
358
-
// In the case that title bar customization is not supported, hide the custom title bar
359
-
// element.
363
+
// In the case that title bar customization is not supported, hide the custom title bar
364
+
// element.
360
365
AppTitleBar.Visibility=Visibility.Collapsed;
361
366
}
362
367
}
@@ -419,7 +424,7 @@ To learn more about acceptable title bar content and recommended UI patterns, se
419
424
420
425
### [Windows App SDK](#tab/wasdk)
421
426
422
-
> (Supported on Windows 10 since Windows App SDK 1.2 and fully supported on Windows 11. See [Platform options](#platform-options) for more info.)
427
+
> (Supported on Windows 10 since Windows App SDK 1.2 and fully supported on Windows 11. See [Platform options](#platform-options) for more info.)
423
428
424
429
When you extend your content into the title bar area, the system by default retains the entire title bar area except for the caption buttons as the drag region. If you don't place interactive content in your title bar, you can leave this default drag region as-is. If you place interactive content in your title bar, you need to specify the drag regions, which we cover in the next section.
425
430
@@ -554,7 +559,7 @@ You can place interactive controls, like buttons, menus, or a search box, in the
554
559
555
560
### [Windows App SDK](#tab/wasdk)
556
561
557
-
> (Supported on Windows 10 since Windows App SDK 1.2 and fully supported on Windows 11. See [Platform options](#platform-options) for more info.)
562
+
> (Supported on Windows 10 since Windows App SDK 1.2 and fully supported on Windows 11. See [Platform options](#platform-options) for more info.)
558
563
559
564
If you add interactive content in the title bar area, you should define explicit drag regions around that content so that users can interact with it. After you set a custom drag region, the default drag region is removed and the system does not reserve any mandatory drag region. You are responsible for ensuring that there is enough space in your title bar for your users to move your window.
560
565
@@ -612,8 +617,8 @@ public MainWindow()
612
617
m_AppWindow=GetAppWindowForCurrentWindow();
613
618
614
619
// Check to see if customization is supported.
615
-
// The method returns true on Windows 10 since Windows App SDK 1.2, and on all versions of
616
-
// Windows App SDK on Windows 11.
620
+
// The method returns true on Windows 10 since Windows App SDK 1.2, and on all versions of
621
+
// Windows App SDK on Windows 11.
617
622
if (AppWindowTitleBar.IsCustomizationSupported())
618
623
{
619
624
vartitleBar=m_AppWindow.TitleBar;
@@ -623,8 +628,8 @@ public MainWindow()
623
628
}
624
629
else
625
630
{
626
-
// In the case that title bar customization is not supported, hide the custom title bar
627
-
// element.
631
+
// In the case that title bar customization is not supported, hide the custom title bar
// The method returns true on Windows 10 since Windows App SDK 1.2, and on all versions of
700
-
// Windows App SDK on Windows 11.
704
+
// The method returns true on Windows 10 since Windows App SDK 1.2, and on all versions of
705
+
// Windows App SDK on Windows 11.
701
706
if (AppWindowTitleBar.IsCustomizationSupported()
702
707
&&appWindow.TitleBar.ExtendsContentIntoTitleBar)
703
708
{
@@ -801,7 +806,7 @@ Here, the [AutoSuggestBox](/uwp/api/Windows.UI.Xaml.Controls.AutoSuggestBox) ele
801
806
802
807
#### [Windows App SDK](#tab/wasdk)
803
808
804
-
> (Supported on Windows 10 since Windows App SDK 1.2 and fully supported on Windows 11. See [Platform options](#platform-options) for more info.)
809
+
> (Supported on Windows 10 since Windows App SDK 1.2 and fully supported on Windows 11. See [Platform options](#platform-options) for more info.)
805
810
806
811
The system reserves the upper-left or upper-right corner of the app window for the system caption buttons (minimize, maximize/restore, close). The system retains control of the caption button area to guarantee that minimum functionality is provided for dragging, minimizing, maximizing, and closing the window. The system draws the Close button in the upper-right for left-to-right languages and the upper-left for right-to-left languages.
807
812
@@ -908,7 +913,7 @@ When you extend your app content into the title bar area, you can make the backg
908
913
909
914
### [Windows App SDK](#tab/wasdk)
910
915
911
-
> (Supported on Windows 10 since Windows App SDK 1.2 and fully supported on Windows 11. See [Platform options](#platform-options) for more info.)
916
+
> (Supported on Windows 10 since Windows App SDK 1.2 and fully supported on Windows 11. See [Platform options](#platform-options) for more info.)
912
917
913
918
These title bar properties can be transparent:
914
919
@@ -1044,7 +1049,7 @@ private void CoreWindow_Activated(CoreWindow sender, WindowActivatedEventArgs ar
1044
1049
1045
1050
### [Windows App SDK](#tab/wasdk)
1046
1051
1047
-
> (Supported on Windows 10 since Windows App SDK 1.2 and fully supported on Windows 11. See [Platform options](#platform-options) for more info.)
1052
+
> (Supported on Windows 10 since Windows App SDK 1.2 and fully supported on Windows 11. See [Platform options](#platform-options) for more info.)
1048
1053
1049
1054
To reset or switch to the system title bar while your app is running, you can call [AppWindowTitleBar.ResetToDefault](/windows/windows-app-sdk/api/winrt/microsoft.ui.windowing.appwindowtitlebar.resettodefault).
1050
1055
@@ -1068,7 +1073,7 @@ If you add support for _full screen_ or _compact overlay_ modes to your app, you
1068
1073
1069
1074
### [Windows App SDK](#tab/wasdk)
1070
1075
1071
-
> (Supported on Windows 10 since Windows App SDK 1.2 and fully supported on Windows 11. See [Platform options](#platform-options) for more info.)
1076
+
> (Supported on Windows 10 since Windows App SDK 1.2 and fully supported on Windows 11. See [Platform options](#platform-options) for more info.)
1072
1077
1073
1078
When your app runs in _full screen_ mode, the system hides the title bar and caption control buttons. You can handle the [AppWindow.Changed](/windows/windows-app-sdk/api/winrt/microsoft.ui.windowing.appwindow.changed) event and check the event args [DidPresenterChange](/windows/windows-app-sdk/api/winrt/microsoft.ui.windowing.appwindowchangedeventargs.didpresenterchange) property to determine if you should show, hide, or change the title bar in response to a new window presentation.
0 commit comments