Skip to content
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

Adding accessible context menus to TabView pages #1664

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions WinUIGallery/ControlPages/TabViewPage.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Page
<Page
x:Class="WinUIGallery.ControlPages.TabViewPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Expand All @@ -9,6 +9,10 @@
xmlns:local1="using:WinUIGallery.ControlPages"
mc:Ignorable="d">

<Page.Resources>
<MenuFlyout x:Name="TabViewContextMenu" Opening="TabViewContextMenu_Opening" />
</Page.Resources>

<StackPanel>
<local:ControlExample HeaderText="A TabView with support for adding, closing, and rearranging tabs" CSharpSource="TabView\TabViewBasicSample_cs.txt">
<local:ControlExample.Example>
Expand All @@ -25,19 +29,19 @@
<local:ControlExample.Example>
<TabView SelectedIndex="0" Margin="-12" MinHeight="475" AddTabButtonClick="TabView_AddButtonClick" TabCloseRequested="TabView_TabCloseRequested">
<TabView.TabItems>
<TabViewItem Header="Document 0">
<TabViewItem Header="Document 0" ContextFlyout="{x:Bind TabViewContextMenu}">
<TabViewItem.IconSource>
<SymbolIconSource Symbol="Placeholder" />
</TabViewItem.IconSource>
<samplepages:SamplePage1 />
</TabViewItem>
<TabViewItem Header="Document 1">
<TabViewItem Header="Document 1" ContextFlyout="{x:Bind TabViewContextMenu}">
<TabViewItem.IconSource>
<SymbolIconSource Symbol="Placeholder" />
</TabViewItem.IconSource>
<samplepages:SamplePage2 />
</TabViewItem>
<TabViewItem Header="Document 2">
<TabViewItem Header="Document 2" ContextFlyout="{x:Bind TabViewContextMenu}">
<TabViewItem.IconSource>
<SymbolIconSource Symbol="Placeholder" />
</TabViewItem.IconSource>
Expand Down Expand Up @@ -79,7 +83,7 @@
<TabView x:Name="TabViewItemsSourceSample" SelectedIndex="0" Margin="-12" MinHeight="475" TabItemsSource="{x:Bind myDatas, Mode=OneWay}" AddTabButtonClick="TabViewItemsSourceSample_AddTabButtonClick" TabCloseRequested="TabViewItemsSourceSample_TabCloseRequested">
<TabView.TabItemTemplate>
<DataTemplate x:DataType="local1:MyData">
<TabViewItem Header="{x:Bind DataHeader}" IconSource="{x:Bind DataIconSource}" Content="{x:Bind DataContent}" />
<TabViewItem Header="{x:Bind DataHeader}" IconSource="{x:Bind DataIconSource}" Content="{x:Bind DataContent}" ContextFlyout="{x:Bind TabViewContextMenu}" />
</DataTemplate>
</TabView.TabItemTemplate >
</TabView>
Expand Down Expand Up @@ -172,19 +176,19 @@
<local:ControlExample.Example>
<TabView x:Name="TabView3" SelectedIndex="0" Margin="-12" IsAddTabButtonVisible="False" MinHeight="475">
<TabView.TabItems>
<TabViewItem Header="Home" IsClosable="False">
<TabViewItem Header="Home" IsClosable="False" ContextFlyout="{x:Bind TabViewContextMenu}">
<TabViewItem.IconSource>
<SymbolIconSource Symbol="Home" />
</TabViewItem.IconSource>
<samplepages:SamplePage1 />
</TabViewItem>
<TabViewItem Header="Tab 2 Has Longer Text" IsClosable="False">
<TabViewItem Header="Tab 2 Has Longer Text" IsClosable="False" ContextFlyout="{x:Bind TabViewContextMenu}">
<TabViewItem.IconSource>
<SymbolIconSource Symbol="MusicInfo" />
</TabViewItem.IconSource>
<samplepages:SamplePage2 />
</TabViewItem>
<TabViewItem Header="Third Tab" IsClosable="False">
<TabViewItem Header="Third Tab" IsClosable="False" ContextFlyout="{x:Bind TabViewContextMenu}">
<TabViewItem.IconSource>
<SymbolIconSource Symbol="Placeholder" />
</TabViewItem.IconSource>
Expand Down Expand Up @@ -214,19 +218,19 @@
<local:ControlExample.Example>
<TabView x:Name="TabView4" SelectedIndex="0" Margin="-12" IsAddTabButtonVisible="False" MinHeight="475">
<TabView.TabItems>
<TabViewItem Header="Home">
<TabViewItem Header="Home" ContextFlyout="{x:Bind TabViewContextMenu}">
<TabViewItem.IconSource>
<SymbolIconSource Symbol="Home" />
</TabViewItem.IconSource>
<samplepages:SamplePage1 />
</TabViewItem>
<TabViewItem Header="Tab 2 Has Longer Text">
<TabViewItem Header="Tab 2 Has Longer Text" ContextFlyout="{x:Bind TabViewContextMenu}">
<TabViewItem.IconSource>
<SymbolIconSource Symbol="MusicInfo" />
</TabViewItem.IconSource>
<samplepages:SamplePage2 />
</TabViewItem>
<TabViewItem Header="Third Tab">
<TabViewItem Header="Third Tab" ContextFlyout="{x:Bind TabViewContextMenu}">
<TabViewItem.IconSource>
<SymbolIconSource Symbol="Placeholder" />
</TabViewItem.IconSource>
Expand Down Expand Up @@ -259,17 +263,17 @@

<TabView SelectedIndex="0" IsAddTabButtonVisible="False" MinWidth="490" TabWidthMode="SizeToContent">
<TabView.TabItems>
<TabViewItem Header="CMD Prompt" IsClosable="False">
<TabViewItem Header="CMD Prompt" IsClosable="False" ContextFlyout="{x:Bind TabViewContextMenu}">
<TabViewItem.IconSource>
<BitmapIconSource UriSource="ms-appx:///Assets/TabViewIcons/cmd.png" ShowAsMonochrome="False" />
</TabViewItem.IconSource>
</TabViewItem>
<TabViewItem Header="PowerShell" IsClosable="False">
<TabViewItem Header="PowerShell" IsClosable="False" ContextFlyout="{x:Bind TabViewContextMenu}">
<TabViewItem.IconSource>
<BitmapIconSource UriSource="ms-appx:///Assets/TabViewIcons/powershell.png" ShowAsMonochrome="False" />
</TabViewItem.IconSource>
</TabViewItem>
<TabViewItem Header="Windows Subsystem for Linux" IsClosable="False">
<TabViewItem Header="Windows Subsystem for Linux" IsClosable="False" ContextFlyout="{x:Bind TabViewContextMenu}">
<TabViewItem.IconSource>
<BitmapIconSource UriSource="ms-appx:///Assets/TabViewIcons/linux.png" ShowAsMonochrome="False" />
</TabViewItem.IconSource>
Expand Down
Loading