diff --git a/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/TabViewTests/TabViewPage.xaml b/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/TabViewTests/TabViewPage.xaml
index 2920d9ff0ce4..335ee718bc20 100644
--- a/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/TabViewTests/TabViewPage.xaml
+++ b/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/TabViewTests/TabViewPage.xaml
@@ -1,23 +1,24 @@
-
+
+ mc:Ignorable="d">
-
+
-
-
-
-
-
+
+
+
+
-
+
+
@@ -53,6 +54,15 @@
+
+
+
+
+
+
+
+
+
@@ -111,18 +121,19 @@
-
-
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+ Shop text
+
+
+
+
+
+
+
+ Emoji text
+
+
+
+
+
+
+
+
+
+
+
+ This tab can't be closed.
+
+
+
+
+
+
+
+
+
+ This tab can't be selected.
+
+
+
+
+
+
+
+
+
Contact text
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
-
-
-
-
+
+
+
+
- Disabled tab state:
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
+
diff --git a/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/TabViewTests/TabViewPage.xaml.cs b/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/TabViewTests/TabViewPage.xaml.cs
index f16ad78f144b..a71f23a4438b 100644
--- a/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/TabViewTests/TabViewPage.xaml.cs
+++ b/src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/TabViewTests/TabViewPage.xaml.cs
@@ -10,6 +10,8 @@
using Windows.UI;
using System.Windows.Input;
using Windows.UI.Xaml.Automation;
+using Windows.UI.Xaml.Shapes;
+using System.Reflection;
using TabView = Microsoft.UI.Xaml.Controls.TabView;
using TabViewItem = Microsoft.UI.Xaml.Controls.TabViewItem;
@@ -23,9 +25,9 @@
using MUXControlsTestApp.Utilities;
using System.Threading.Tasks;
using Uno.UI.Samples.Controls;
-using System.Linq;
+using UITests.Microsoft_UI_Xaml_Controls.TabViewTests;
-namespace UITests.Microsoft_UI_Xaml_Controls.TabViewTests
+namespace MUXControlsTestApp
{
public partial class TabDataItem : DependencyObject
{
@@ -35,7 +37,7 @@ public partial class TabDataItem : DependencyObject
}
[Sample("TabView", "MUX")]
- public sealed partial class TabViewPage : Page
+ public sealed partial class TabViewPage : TestPage
{
int _newTabNumber = 1;
SymbolIconSource _iconSource;
@@ -43,10 +45,12 @@ public sealed partial class TabViewPage : Page
public TabViewPage()
{
this.InitializeComponent();
- DisabledTab.Loaded += TabViewPage_Loaded;
+
_iconSource = new SymbolIconSource();
_iconSource.Symbol = Symbol.Placeholder;
+ Tabs.TabItemsChanged += Tabs_TabItemsChanged;
+
ObservableCollection itemSource = new ObservableCollection();
for (int i = 0; i < 5; i++)
{
@@ -57,19 +61,22 @@ public TabViewPage()
itemSource.Add(item);
}
DataBindingTabView.TabItemsSource = itemSource;
- }
- private void TabViewPage_Loaded(object sender, RoutedEventArgs e)
- {
- var layoutRoot = (Grid)VisualTreeHelper.GetChild(DisabledTab, 0);
- VisualStateManager.GetVisualStateGroups(layoutRoot).Single(s => s.Name == "DisabledStates").CurrentStateChanged += CurrentStateChanged;
+ backgroundColorCache = BackgroundGrid.Background;
+ activeTabContentBackgroundBrushCache = FirstTabContent.Background;
+ CacheFirstTabSelectedBackgroundPathFill();
}
- private void CurrentStateChanged(object sender, VisualStateChangedEventArgs e)
+ private void Tabs_TabItemsChanged(TabView sender, Windows.Foundation.Collections.IVectorChangedEventArgs args)
{
- DisabledTabStateText.Text = "Disabled tab state: " + e.NewState.Name;
+ TabsItemChangedEventArgsTextBlock.Text = args.CollectionChange.ToString();
+ TabsItemChangedEventArgsIndexTextBlock.Text = args.Index.ToString();
}
+ private Brush backgroundColorCache;
+ private Brush activeTabSelectedBackgroundPathBrushCache;
+ private Brush activeTabContentBackgroundBrushCache;
+
protected
#if HAS_UNO
internal
@@ -287,7 +294,7 @@ private void OnTabDragStarting(object sender, TabViewTabDragStartingEventArgs e)
e.Data.RequestedOperation = DataPackageOperation.Move;
}
- private void OnTabStripDragOver(object sender, Windows.UI.Xaml.DragEventArgs e)
+ private void OnTabStripDragOver(object sender, DragEventArgs e)
{
if (e.DataView.Properties.ContainsKey(DataIdentifier))
{
@@ -295,7 +302,7 @@ private void OnTabStripDragOver(object sender, Windows.UI.Xaml.DragEventArgs e)
}
}
- private void OnTabStripDrop(object sender, Windows.UI.Xaml.DragEventArgs e)
+ private void OnTabStripDrop(object sender, DragEventArgs e)
{
// This event is called when we're dragging between different TabViews
// It is responsible for handling the drop of the item into the second TabView
@@ -355,13 +362,13 @@ private void OnTabStripDrop(object sender, Windows.UI.Xaml.DragEventArgs e)
public void SetTabViewWidth_Click(object sender, RoutedEventArgs e)
{
// This is the smallest width that fits our content without any scrolling.
- Tabs.Width = 740;
+ Tabs.Width = 752;
}
public void GetScrollButtonsVisible_Click(object sender, RoutedEventArgs e)
{
- var scrollDecrease = VisualTreeUtils.FindVisualChildByName(Tabs, "ScrollDecreaseButton") as FrameworkElement;
- var scrollIncrease = VisualTreeUtils.FindVisualChildByName(Tabs, "ScrollIncreaseButton") as FrameworkElement;
+ var scrollDecrease = VisualTreeUtils.FindVisualChildByName(Tabs, "ScrollDecreaseButtonContainer") as FrameworkElement;
+ var scrollIncrease = VisualTreeUtils.FindVisualChildByName(Tabs, "ScrollIncreaseButtonContainer") as FrameworkElement;
if (scrollDecrease.Visibility == Visibility.Visible && scrollIncrease.Visibility == Visibility.Visible)
{
ScrollButtonsVisible.Text = "True";
@@ -408,17 +415,17 @@ public void GetScrollIncreaseButtonEnabled_Click(object sender, RoutedEventArgs
private void TabViewSizingPageButton_Click(object sender, RoutedEventArgs e)
{
- this.GetFrame().Navigate(typeof(TabViewSizingPage));
+ this.Frame.Navigate(typeof(TabViewSizingPage));
}
private void TabViewTabClosingBehaviorButton_Click(object sender, RoutedEventArgs e)
{
- this.GetFrame().Navigate(typeof(TabViewTabClosingBehaviorPage));
+ this.Frame.Navigate(typeof(TabViewTabClosingBehaviorPage));
}
private void TabViewTabItemsSourcePageButton_Click(object sender, RoutedEventArgs e)
{
- this.GetFrame().Navigate(typeof(TabViewTabItemsSourcePage));
+ this.Frame.Navigate(typeof(TabViewTabItemsSourcePage));
}
private void ShortLongTextButton_Click(object sender, RoutedEventArgs e)
@@ -427,64 +434,125 @@ private void ShortLongTextButton_Click(object sender, RoutedEventArgs e)
LongHeaderTab.Header = "long long long long long long long long";
}
- private void GetScrollDecreaseButtonToolTipButton_Click(object sender, RoutedEventArgs e)
+ private void HomeTabOverlapCheck_Click(object sender, RoutedEventArgs e)
{
- if (VisualTreeUtils.FindVisualChildByName(Tabs, "ScrollDecreaseButton") is RepeatButton scrollDecreaseButton)
- {
- GetToolTipStringForUIElement(scrollDecreaseButton, ScrollDecreaseButtonToolTipTextBlock);
- }
+ var redBrush = new SolidColorBrush();
+ redBrush.Color = Colors.Red;
+ BackgroundGrid.Background = redBrush;
+
+ var tabBrush = new SolidColorBrush();
+ tabBrush.Color = Colors.Blue;
+ SetFirstTabSelectedBackgroundPathFill(tabBrush);
+
+ var contentBrush = new SolidColorBrush();
+ contentBrush.Color = Colors.Green;
+ FirstTabContent.Background = contentBrush;
}
- private void GetScrollIncreaseButtonToolTipButton_Click(object sender, RoutedEventArgs e)
+ private void SetActiveTabTransparent_Click(object sender, RoutedEventArgs e)
{
- if (VisualTreeUtils.FindVisualChildByName(Tabs, "ScrollIncreaseButton") is RepeatButton scrollIncreaseButton)
+ var tabBrush = new SolidColorBrush();
+ tabBrush.Color = Colors.Transparent;
+ SetFirstTabSelectedBackgroundPathFill(tabBrush);
+ }
+
+ private void SetActiveContentTransparent_Click(object sender, RoutedEventArgs e)
+ {
+ var contentBrush = new SolidColorBrush();
+ contentBrush.Color = Colors.Transparent;
+ FirstTabContent.Background = contentBrush;
+ }
+
+ private void ClearOverlapCheck_Click(object sender, RoutedEventArgs e)
+ {
+ BackgroundGrid.Background = backgroundColorCache;
+
+ if (activeTabSelectedBackgroundPathBrushCache != null)
{
- GetToolTipStringForUIElement(scrollIncreaseButton, ScrollIncreaseButtonToolTipTextBlock);
+ FrameworkElement selectedBackgroundPath = FindFrameworkElementWithName("SelectedBackgroundPath", FirstTab);
+ if (selectedBackgroundPath != null)
+ {
+ (selectedBackgroundPath as Path).Fill = activeTabSelectedBackgroundPathBrushCache;
+ }
+ }
+
+ if (activeTabContentBackgroundBrushCache != null)
+ {
+ FirstTabContent.Background = activeTabContentBackgroundBrushCache;
}
}
- private void GetSecondTabHeaderForegroundButton_Click(object sender, RoutedEventArgs e)
+ private void CacheFirstTabSelectedBackgroundPathFill()
{
- if (FindVisualChildByName(SecondTab, "ContentPresenter") is ContentPresenter presenter
- && presenter.Foreground is SolidColorBrush brush)
+ FrameworkElement selectedBackgroundPath = FindFrameworkElementWithName("SelectedBackgroundPath", FirstTab);
+ if (selectedBackgroundPath != null)
{
- SecondTabHeaderForegroundTextBlock.Text = brush.Color.ToString();
+ activeTabSelectedBackgroundPathBrushCache = (selectedBackgroundPath as Path).Fill;
}
}
- //TODO: Move to MUX test page base when TreeView PR is merged
- public static DependencyObject FindVisualChildByName(FrameworkElement parent, string name)
+ private void SetFirstTabSelectedBackgroundPathFill(Brush newBrush)
{
- if (parent.Name == name)
+ FrameworkElement selectedBackgroundPath = FindFrameworkElementWithName("SelectedBackgroundPath", FirstTab);
+ if (selectedBackgroundPath != null)
{
- return parent;
+ (selectedBackgroundPath as Path).Fill = newBrush;
}
+ }
- int childrenCount = VisualTreeHelper.GetChildrenCount(parent);
-
- for (int i = 0; i < childrenCount; i++)
+ private FrameworkElement FindFrameworkElementWithName(string name, DependencyObject startNode)
+ {
+ int count = VisualTreeHelper.GetChildrenCount(startNode);
+ for (int i = 0; i < count; i++)
{
- FrameworkElement childAsFE = VisualTreeHelper.GetChild(parent, i) as FrameworkElement;
-
- if (childAsFE != null)
+ DependencyObject current = VisualTreeHelper.GetChild(startNode, i);
+ if ((current.GetType()).Equals(typeof(FrameworkElement)) || (current.GetType().GetTypeInfo().IsSubclassOf(typeof(FrameworkElement))))
{
- DependencyObject result = FindVisualChildByName(childAsFE, name);
-
- if (result != null)
+ FrameworkElement fe = (FrameworkElement)current;
+ if (fe.Name == name)
{
- return result;
+ return fe;
}
}
+ var result = FindFrameworkElementWithName(name, current);
+ if (result != null)
+ {
+ return result;
+ }
}
-
return null;
}
- // Uno Specific sample subpage navigation
- private Frame GetFrame()
+ private void SetColorsButton_Click(object sender, RoutedEventArgs e)
+ {
+ var foregroundBrush = new SolidColorBrush();
+ foregroundBrush.Color = Colors.Blue;
+ SecondTab.Foreground = foregroundBrush;
+ var backgroundBrush = new SolidColorBrush();
+ backgroundBrush.Color = Colors.Purple;
+ SecondTab.Background = backgroundBrush;
+ }
+
+ private void ClearColorsButton_Click(object sender, RoutedEventArgs e)
{
- NavFrameGrid.Visibility = Visibility.Visible;
- return NavFrame;
+ SecondTab.ClearValue(ForegroundProperty);
+ SecondTab.ClearValue(BackgroundProperty);
+ }
+
+ private void GetScrollDecreaseButtonToolTipButton_Click(object sender, RoutedEventArgs e)
+ {
+ if (VisualTreeUtils.FindVisualChildByName(Tabs, "ScrollDecreaseButton") is RepeatButton scrollDecreaseButton)
+ {
+ GetToolTipStringForUIElement(scrollDecreaseButton, ScrollDecreaseButtonToolTipTextBlock);
+ }
+ }
+
+ private void GetScrollIncreaseButtonToolTipButton_Click(object sender, RoutedEventArgs e)
+ {
+ if (VisualTreeUtils.FindVisualChildByName(Tabs, "ScrollIncreaseButton") is RepeatButton scrollIncreaseButton)
+ {
+ GetToolTipStringForUIElement(scrollIncreaseButton, ScrollIncreaseButtonToolTipTextBlock);
+ }
}
}
}
diff --git a/src/Uno.UI.FluentTheme.v2/themeresources_v2.xaml b/src/Uno.UI.FluentTheme.v2/themeresources_v2.xaml
index 36ed818fda2c..a0804a52fac8 100644
--- a/src/Uno.UI.FluentTheme.v2/themeresources_v2.xaml
+++ b/src/Uno.UI.FluentTheme.v2/themeresources_v2.xaml
@@ -23107,7 +23107,10 @@
-
+
+
diff --git a/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/TabView/TabViewTests.cs b/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/TabView/TabViewTests.cs
index 079d8c3dc504..9f34ecc07f9e 100644
--- a/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/TabView/TabViewTests.cs
+++ b/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/TabView/TabViewTests.cs
@@ -78,7 +78,7 @@ await RunOnUIThread.ExecuteAsync(() =>
await TestServices.WindowHelper.WaitForLoaded(Content as FrameworkElement);
await RunOnUIThread.ExecuteAsync(() =>
- {
+ {
Log.Comment("Verify a selected tab exists");
VerifySelectedItem("Tab 0");
diff --git a/src/Uno.UI/Microsoft/UI/Xaml/Controls/TabView/TabView.cs b/src/Uno.UI/Microsoft/UI/Xaml/Controls/TabView/TabView.cs
index c0939ea60eb8..f6900e36a96c 100644
--- a/src/Uno.UI/Microsoft/UI/Xaml/Controls/TabView/TabView.cs
+++ b/src/Uno.UI/Microsoft/UI/Xaml/Controls/TabView/TabView.cs
@@ -1,6 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
-// MUX Reference TabView.cpp, commit 5f52761
+// MUX Reference TabView.cpp, commit c8d3b4a
#pragma warning disable 105 // remove when moving to WinUI tree
@@ -839,14 +839,9 @@ private void BringSelectedTabIntoView()
}
}
- //TODO Uno: The second parameter is needed, as OnItemsChanged may get called before OnApplyTemplate due to control lifecycle differences
+ //TODO Uno workaround: The second parameter is needed, as OnItemsChanged may get called before OnApplyTemplate due to control lifecycle differences
internal void OnItemsChanged(object item, TabViewListView tabListView)
{
- if (m_isDragging)
- {
- return;
- }
-
var args = item as IVectorChangedEventArgs;
if (args != null)
{
@@ -989,11 +984,13 @@ private void OnListViewDragItemsCompleted(object sender, DragItemsCompletedEvent
{
m_isDragging = false;
- // Selection change was disabled during drag, update SelectedIndex now
+ // Selection may have changed during drag if dragged outside, so we update SelectedIndex again.
if (m_listView is { } listView)
{
SelectedIndex = listView.SelectedIndex;
SelectedItem = listView.SelectedItem;
+
+ BringSelectedTabIntoView();
}
var item = args.Items[0];