Skip to content

Commit 5300790

Browse files
Merge pull request #3627 from MicrosoftDocs/main638216860973927719sync_temp
For protected CLA branch, push strategy should use PR and merge to target branch method to work around git push error
2 parents 2e516e0 + 6e43783 commit 5300790

File tree

1 file changed

+57
-52
lines changed

1 file changed

+57
-52
lines changed

hub/apps/develop/title-bar.md

Lines changed: 57 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
description: Customize the title bar of a desktop app to match the personality of the app.
33
title: Title bar customization
44
template: detail.hbs
5-
ms.date: 06/15/2022
5+
ms.date: 05/27/2023
66
ms.topic: article
77
keywords: windows 10, uwp, title bar
88
doc-status: Draft
@@ -51,16 +51,16 @@ The exact features of the title bar and the options available to customize it de
5151
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.
5252

5353
> [!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.
6464
6565
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).
6666

@@ -77,13 +77,13 @@ You can use AppWindow APIs with any UI framework that the Windows App SDK suppor
7777
7878
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.
7979

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).
8181

82-
This table describes the differences between Window and AppWindow.
82+
This table describes the differences between Window and AppWindow.
8383

8484
| Feature | Window class | AppWindow class |
8585
| - | - | - |
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). |
8787
| Simple customization | Title | Title, Colors, Icon and System menu |
8888
| Replace system title bar | Window.ExtendsContentIntoTitleBar | AppWindowTitleBar.ExtendsContentIntoTitleBar |
8989
| 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
128128

129129
### [Windows App SDK](#tab/wasdk)
130130

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.)
132132
133133
These examples show how to get an instance of [AppWindow](/windows/windows-app-sdk/api/winrt/microsoft.ui.windowing.appwindowtitlebar) and set its properties.
134134

@@ -167,8 +167,8 @@ This example shows how to get an instance of [AppWindowTitleBar](/windows/window
167167
private bool SetTitleBarColors()
168168
{
169169
// 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
171+
// Windows App SDK on Windows 11.
172172
if (AppWindowTitleBar.IsCustomizationSupported())
173173
{
174174
if (m_AppWindow is null)
@@ -178,8 +178,8 @@ private bool SetTitleBarColors()
178178
var titleBar = m_AppWindow.TitleBar;
179179

180180
// Set active window colors
181-
// Note: No effect when app is running on Windows 10 since color customization is not
182-
// supported.
181+
// Note: No effect when app is running on Windows 10 since color customization is not
182+
// supported.
183183
titleBar.ForegroundColor = Colors.White;
184184
titleBar.BackgroundColor = Colors.Green;
185185
titleBar.ButtonForegroundColor = Colors.White;
@@ -190,8 +190,8 @@ private bool SetTitleBarColors()
190190
titleBar.ButtonPressedBackgroundColor = Colors.LightGreen;
191191

192192
// Set inactive window colors
193-
// Note: No effect when app is running on Windows 10 since color customization is not
194-
// supported.
193+
// Note: No effect when app is running on Windows 10 since color customization is not
194+
// supported.
195195
titleBar.InactiveForegroundColor = Colors.Gainsboro;
196196
titleBar.InactiveBackgroundColor = Colors.SeaGreen;
197197
titleBar.ButtonInactiveForegroundColor = Colors.Gainsboro;
@@ -250,8 +250,13 @@ public MainWindow()
250250
}
251251
```
252252

253-
> [!CAUTION]
254-
> `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+
```
255260

256261
> [!NOTE]
257262
> 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
325330
326331
### [Windows App SDK](#tab/wasdk)
327332

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.)
329334
330335
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`.
331336

@@ -345,8 +350,8 @@ public MainWindow()
345350

346351
m_AppWindow = GetAppWindowForCurrentWindow();
347352
// 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.
350355
if (AppWindowTitleBar.IsCustomizationSupported())
351356
{
352357
var titleBar = m_AppWindow.TitleBar;
@@ -355,8 +360,8 @@ public MainWindow()
355360
}
356361
else
357362
{
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.
360365
AppTitleBar.Visibility = Visibility.Collapsed;
361366
}
362367
}
@@ -419,7 +424,7 @@ To learn more about acceptable title bar content and recommended UI patterns, se
419424

420425
### [Windows App SDK](#tab/wasdk)
421426

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.)
423428
424429
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.
425430

@@ -554,7 +559,7 @@ You can place interactive controls, like buttons, menus, or a search box, in the
554559

555560
### [Windows App SDK](#tab/wasdk)
556561

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.)
558563
559564
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.
560565

@@ -612,8 +617,8 @@ public MainWindow()
612617
m_AppWindow = GetAppWindowForCurrentWindow();
613618

614619
// 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.
617622
if (AppWindowTitleBar.IsCustomizationSupported())
618623
{
619624
var titleBar = m_AppWindow.TitleBar;
@@ -623,8 +628,8 @@ public MainWindow()
623628
}
624629
else
625630
{
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
632+
// element.
628633
AppTitleBar.Visibility = Visibility.Collapsed;
629634

630635
// Show alternative UI for any functionality in
@@ -636,8 +641,8 @@ public MainWindow()
636641
private void AppTitleBar_Loaded(object sender, RoutedEventArgs e)
637642
{
638643
// Check to see if customization is supported.
639-
// The method returns true on Windows 10 since Windows App SDK 1.2, and on all versions of
640-
// Windows App SDK on Windows 11.
644+
// The method returns true on Windows 10 since Windows App SDK 1.2, and on all versions of
645+
// Windows App SDK on Windows 11.
641646
if (AppWindowTitleBar.IsCustomizationSupported())
642647
{
643648
SetDragRegionForCustomTitleBar(m_AppWindow);
@@ -647,8 +652,8 @@ private void AppTitleBar_Loaded(object sender, RoutedEventArgs e)
647652
private void AppTitleBar_SizeChanged(object sender, SizeChangedEventArgs e)
648653
{
649654
// Check to see if customization is supported.
650-
// The method returns true on Windows 10 since Windows App SDK 1.2, and on all versions of
651-
// Windows App SDK on Windows 11.
655+
// The method returns true on Windows 10 since Windows App SDK 1.2, and on all versions of
656+
// Windows App SDK on Windows 11.
652657
if (AppWindowTitleBar.IsCustomizationSupported()
653658
&& m_AppWindow.TitleBar.ExtendsContentIntoTitleBar)
654659
{
@@ -696,8 +701,8 @@ private double GetScaleAdjustment()
696701
private void SetDragRegionForCustomTitleBar(AppWindow appWindow)
697702
{
698703
// Check to see if customization is supported.
699-
// 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.
701706
if (AppWindowTitleBar.IsCustomizationSupported()
702707
&& appWindow.TitleBar.ExtendsContentIntoTitleBar)
703708
{
@@ -801,7 +806,7 @@ Here, the [AutoSuggestBox](/uwp/api/Windows.UI.Xaml.Controls.AutoSuggestBox) ele
801806

802807
#### [Windows App SDK](#tab/wasdk)
803808

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.)
805810
806811
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.
807812

@@ -908,7 +913,7 @@ When you extend your app content into the title bar area, you can make the backg
908913

909914
### [Windows App SDK](#tab/wasdk)
910915

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.)
912917
913918
These title bar properties can be transparent:
914919

@@ -1044,7 +1049,7 @@ private void CoreWindow_Activated(CoreWindow sender, WindowActivatedEventArgs ar
10441049

10451050
### [Windows App SDK](#tab/wasdk)
10461051

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.)
10481053
10491054
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).
10501055

@@ -1068,7 +1073,7 @@ If you add support for _full screen_ or _compact overlay_ modes to your app, you
10681073

10691074
### [Windows App SDK](#tab/wasdk)
10701075

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.)
10721077
10731078
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.
10741079

@@ -1086,8 +1091,8 @@ public MainWindow()
10861091
private void AppWindow_Changed(AppWindow sender, AppWindowChangedEventArgs args)
10871092
{
10881093
// Check to see if customization is supported.
1089-
// The method returns true on Windows 10 since Windows App SDK 1.2, and on all versions of
1090-
// Windows App SDK on Windows 11.
1094+
// The method returns true on Windows 10 since Windows App SDK 1.2, and on all versions of
1095+
// Windows App SDK on Windows 11.
10911096
if (args.DidPresenterChange
10921097
&& AppWindowTitleBar.IsCustomizationSupported())
10931098
{
@@ -1181,7 +1186,7 @@ This examples shows all the code described in the Full customization section.
11811186

11821187
### [Windows App SDK](#tab/wasdk)
11831188

1184-
> (Supported on Windows 10 since Windows App SDK 1.2 and fully supported on Windows 11. See [Platform options](#platform-options) for more info.)
1189+
> (Supported on Windows 10 since Windows App SDK 1.2 and fully supported on Windows 11. See [Platform options](#platform-options) for more info.)
11851190
11861191
```xaml
11871192
<Window
@@ -1273,8 +1278,8 @@ namespace WASDK_ExtendedTitleBar
12731278
m_AppWindow.Changed += AppWindow_Changed;
12741279

12751280
// Check to see if customization is supported.
1276-
// The method returns true on Windows 10 since Windows App SDK 1.2, and on all versions
1277-
// of Windows App SDK on Windows 11.
1281+
// The method returns true on Windows 10 since Windows App SDK 1.2, and on all versions
1282+
// of Windows App SDK on Windows 11.
12781283
if (AppWindowTitleBar.IsCustomizationSupported())
12791284
{
12801285
var titleBar = m_AppWindow.TitleBar;
@@ -1284,8 +1289,8 @@ namespace WASDK_ExtendedTitleBar
12841289
}
12851290
else
12861291
{
1287-
// In the case that title bar customization is not supported, hide the custom title
1288-
// bar element.
1292+
// In the case that title bar customization is not supported, hide the custom title
1293+
// bar element.
12891294
AppTitleBar.Visibility = Visibility.Collapsed;
12901295

12911296
// Show alternative UI for any functionality in
@@ -1659,4 +1664,4 @@ private void CoreTitleBar_IsVisibleChanged(CoreApplicationViewTitleBar sender, o
16591664

16601665
- [Acrylic](../design/style/acrylic.md)
16611666
- [Mica](../design/style/mica.md)
1662-
- [Color](../design/style/color.md)
1667+
- [Color](../design/style/color.md)

0 commit comments

Comments
 (0)