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/design/controls/pivot.md
+39-53Lines changed: 39 additions & 53 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,58 +2,27 @@
2
2
description: The Pivot control enables touch-swiping between a small set of content sections.
3
3
title: Pivot
4
4
template: detail.hbs
5
-
ms.date: 04/04/2022
5
+
ms.date: 03/29/2024
6
6
ms.topic: article
7
7
doc-status: Published
8
8
ms.localizationpriority: medium
9
9
---
10
10
11
11
# Pivot
12
12
13
-
The [Pivot](/windows/windows-app-sdk/api/winrt/microsoft.UI.Xaml.Controls.Pivot) control enables touch-swiping between a small set of content sections.
Windows UI Library 2.2 or later includes a new template for this control that uses rounded corners. For more info, see [Corner radius](../style/rounded-corner.md). WinUI is a NuGet package that contains new controls and UI features for Windows apps. For more info, including installation instructions, see [Windows UI Library](/uwp/toolkits/winui/).
<p>If you have the <strong>WinUI 2 Gallery</strong> app installed, click here to <a href="winui2gallery:/item/Pivot">open the app and see the Pivot control in action</a>.</p>
41
-
<ul>
42
-
<li><a href="https://www.microsoft.com/store/productId/9MSVH128X2ZT">Get the WinUI 2 Gallery app (Microsoft Store)</a></li>
43
-
<li><a href="https://github.com/Microsoft/WinUI-Gallery">Get the source code (GitHub)</a></li>
44
-
</ul>
45
-
</td>
46
-
</tr>
47
-
</table>
48
-
49
-
The Pivot control, just like [NavigationView](navigationview.md), underlines the selected item.
13
+
The Pivot control enables touch-swiping between a small set of content sections.
>The Pivot control is not recommended for [Windows 11 design patterns](../basics/app-silhouette.md). When designing for Windows 11, consider using a [NavigationView](navigationview.md) or [TabView](tab-view.md) control instead of a Pivot control. See the [Use NavigationView instead of Pivot](#use-navigationview-instead-of-pivot) section for an example.
19
+
> [!WARNING]
20
+
>The Pivot control is not recommended for [Windows 11 design patterns](../basics/app-silhouette.md). We strongly recommend using one of these alternatives instead:
21
+
>
22
+
> -**WinUI 3** - Use the [SelectorBar](selector-bar.md) control.
23
+
> -**WinUI 2/UWP** - Use a [NavigationView](navigationview.md) or [TabView](tab-view.md) control instead of a Pivot control. See the [Use NavigationView instead of Pivot](#use-navigationview-instead-of-pivot) section for an example.
24
+
25
+
To create a Pivot-like UI when using WinUI 3 and the Windows App SDK, use the [SelectorBar](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.selectorbar) control.
57
26
58
27
To create a tabbed UI, use a [TabView](tab-view.md) control.
59
28
@@ -65,9 +34,22 @@ Some key differences between the NavigationView and Pivot are listed here:
65
34
- Overflow items in a Pivot carousel, while NavigationView uses a menu dropdown overflow so that users can see all items.
66
35
- Pivot handles navigation between content sections, while NavigationView allows for more control over navigation behavior.
> -[Open the WinUI 2 Gallery app and see the Pivot in action](winui2gallery:/item/Pivot). [!INCLUDE [winui-2-gallery](../../../includes/winui-2-gallery.md)]
47
+
48
+
We recommend using the latest [WinUI 2](../../winui/winui2/index.md) to get the most current styles and templates for all controls.
49
+
68
50
## Use NavigationView instead of Pivot
69
51
70
-
If your app's UI uses the Pivot control, then you can convert Pivot to NavigationView with the code below.
52
+
If your app's UI uses the Pivot control, you can convert Pivot to [NavigationView](/windows/winui/api/microsoft.ui.xaml.controls.navigationview) following this example.
71
53
72
54
This XAML creates a NavigationView with 3 sections of content, like the example Pivot in [Create a pivot control](#create-a-pivot-control).
73
55
@@ -128,7 +110,13 @@ This code mimics the Pivot control's built-in navigation experience, minus the t
128
110
129
111
## Create a pivot control
130
112
131
-
This code creates a basic Pivot control with 3 sections of content.
113
+
> [!WARNING]
114
+
>The Pivot control is not recommended for [Windows 11 design patterns](../basics/app-silhouette.md). We strongly recommend using one of these alternatives instead:
115
+
>
116
+
> -**WinUI 3** - Use the [SelectorBar](selector-bar.md) control.
117
+
> -**WinUI 2/UWP** - Use a [NavigationView](navigationview.md) or [TabView](tab-view.md) control instead of a Pivot control. See the [Use NavigationView instead of Pivot](#use-navigationview-instead-of-pivot) section for an example.
118
+
119
+
This XAML creates a basic Pivot control with 3 sections of content.
132
120
133
121
```xaml
134
122
<Pivotx:Name="rootPivot"Title="Category Title">
@@ -149,7 +137,7 @@ This code creates a basic Pivot control with 3 sections of content.
149
137
150
138
### Pivot items
151
139
152
-
Pivot is an [ItemsControl](/windows/windows-app-sdk/api/winrt/microsoft.UI.Xaml.Controls.ItemsControl), so it can contain a collection of items of any type. Any item you add to the Pivot that is not explicitly a [PivotItem](/windows/windows-app-sdk/api/winrt/microsoft.UI.Xaml.Controls.PivotItem) is implicitly wrapped in a PivotItem. Because a Pivot is often used to navigate between pages of content, it's common to populate the [Items](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.itemscontrol.items) collection directly with XAML UI elements. Or, you can set the [ItemsSource](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.itemscontrol.itemssource) property to a data source. Items bound in the ItemsSource can be of any type, but if they aren't explicitly PivotItems, you must define an [ItemTemplate](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.itemscontrol.itemtemplate) and [HeaderTemplate](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.pivot.headertemplate) to specify how the items are displayed.
140
+
Pivot is an [ItemsControl](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.itemscontrol), so it can contain a collection of items of any type. Any item you add to the Pivot that is not explicitly a [PivotItem](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.pivotitem) is implicitly wrapped in a PivotItem. Because a Pivot is often used to navigate between pages of content, it's common to populate the [Items](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.itemscontrol.items) collection directly with XAML UI elements. Or, you can set the [ItemsSource](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.itemscontrol.itemssource) property to a data source. Items bound in the ItemsSource can be of any type, but if they aren't explicitly PivotItems, you must define an [ItemTemplate](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.itemscontrol.itemtemplate) and [HeaderTemplate](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.pivot.headertemplate) to specify how the items are displayed.
153
141
154
142
You can use the [SelectedItem](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.pivot.selecteditem) property to get or set the Pivot's active item. Use the [SelectedIndex](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.pivot.selectedindex) property to get or set the index of the active item.
155
143
@@ -195,17 +183,15 @@ The control comes in two modes:
195
183
- Tapping a pivot label navigates to the corresponding page, and the active pivot label will carousel into the first position.
196
184
- Pivot items in a carousel loop from last to first pivot section.
197
185
198
-
> **Note** Pivot headers should not carousel in a [10ft environment](../devices/designing-for-tv.md). Set the [IsHeaderItemsCarouselEnabled](/windows/windows-app-sdk/api/winrt/microsoft.UI.Xaml.Controls.Pivot.IsHeaderItemsCarouselEnabled) property to **false** if your app will run on Xbox.
199
-
200
-
## Recommendations
201
-
202
-
- Avoid using more than 5 headers when using carousel (round-trip) mode, as looping more than 5 can become confusing.
203
-
204
-
## Get the sample code
205
-
206
-
-[WinUI 2 Gallery sample](https://github.com/Microsoft/WinUI-Gallery) - See all the XAML controls in an interactive format.
186
+
> [!TIP]
187
+
>
188
+
> - Avoid using more than 5 headers when using carousel mode, as looping more than 5 can become confusing.
189
+
> - Pivot headers should not carousel in a [10ft environment](../devices/designing-for-tv.md). Set the [IsHeaderItemsCarouselEnabled](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.pivot.IsHeaderItemsCarouselEnabled) property to `false` if your app will run on Xbox.
0 commit comments