Skip to content
Merged
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
6 changes: 5 additions & 1 deletion WinUIGallery/Samples/ControlPages/TabViewPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
TextWrapping="WrapWholeWords" />

<TabView
BringIntoViewRequested="TabView_BringIntoViewRequested"
MinHeight="475"
Margin="-12"
AddTabButtonClick="TabView_AddButtonClick"
Expand Down Expand Up @@ -271,10 +272,12 @@
<controls:ControlExample.Example>
<TabView
x:Name="TabView3"
BringIntoViewRequested="TabView_BringIntoViewRequested"
MinHeight="475"
Margin="-12"
IsAddTabButtonVisible="False"
SelectedIndex="0">
SelectedIndex="0"
TabWidthMode="SizeToContent">
<TabView.TabItems>
<TabViewItem Header="Home" IsClosable="False">
<TabViewItem.IconSource>
Expand Down Expand Up @@ -378,6 +381,7 @@
TextWrapping="WrapWholeWords" />

<TabView
BringIntoViewRequested="TabView_BringIntoViewRequested"
MinWidth="490"
IsAddTabButtonVisible="False"
SelectedIndex="0"
Expand Down
19 changes: 13 additions & 6 deletions WinUIGallery/Samples/ControlPages/TabViewPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public TabViewPage()
InitializeDataBindingSampleData();
}

#region SharedTabViewLogic
#region SharedTabViewLogic
private void TabView_Loaded(object sender, RoutedEventArgs e)
{
for (int i = 0; i < 3; i++)
Expand All @@ -38,6 +38,13 @@ private void TabView_Loaded(object sender, RoutedEventArgs e)
}
}

private void TabView_BringIntoViewRequested(UIElement sender, BringIntoViewRequestedEventArgs args)
{
// The TabView control is firing this event when TabWidthMode is set to `SizeToContent` or `Compact`.
// This will work around an auto-scroll issue when the page is loaded.
args.Handled = true;
}

private void TabView_AddButtonClick(TabView sender, object args)
{
sender.TabItems.Add(CreateNewTab(sender.TabItems.Count));
Expand Down Expand Up @@ -76,9 +83,9 @@ private TabViewItem CreateNewTab(int index)

return newItem;
}
#endregion
#endregion

#region ItemsSourceSample
#region ItemsSourceSample
private void InitializeDataBindingSampleData()
{
myDatas = new ObservableCollection<MyData>();
Expand Down Expand Up @@ -128,9 +135,9 @@ private void TabViewItemsSourceSample_TabCloseRequested(TabView sender, TabViewT
// Remove the requested MyData object from the collection.
myDatas.Remove(args.Item as MyData);
}
#endregion
#endregion

#region KeyboardAcceleratorSample
#region KeyboardAcceleratorSample
private void NewTabKeyboardAccelerator_Invoked(KeyboardAccelerator sender, KeyboardAcceleratorInvokedEventArgs args)
{
var senderTabView = args.Element as TabView;
Expand Down Expand Up @@ -198,7 +205,7 @@ private void NavigateToNumberedTabKeyboardAccelerator_Invoked(KeyboardAccelerato

args.Handled = true;
}
#endregion
#endregion

private void TabWidthBehaviorComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Expand Down