Skip to content

Commit dcda9f1

Browse files
committed
fix: Avoid generating duplicate TabViewItems
- Fixes issue unoplatform#4899 - The applied Uno specific workaround is reported as issue unoplatform#4925
1 parent b65c563 commit dcda9f1

File tree

1 file changed

+20
-15
lines changed
  • src/Uno.UI/Microsoft/UI/Xaml/Controls/TabView

1 file changed

+20
-15
lines changed

src/Uno.UI/Microsoft/UI/Xaml/Controls/TabView/TabView.cs

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,11 @@ void OnTabContentPresenterLosingFocus(object sender, LosingFocusEventArgs args)
882882

883883
// It is not ideal to call UpdateLayout here, but it is necessary to ensure that the ContentPresenter has expanded its content
884884
// into the live visual tree.
885-
tabContentPresenter.UpdateLayout();
885+
#if IS_UNO
886+
// TODO: Uno specific - issue #4925 - Calling UpdateLayout here causes another Measure of TabListView, which is already in progress
887+
// if this tab was added by data binding. As a result, two copies of each tab would be constructed.
888+
//tabContentPresenter.UpdateLayout();
889+
#endif
886890

887891
if (shouldMoveFocusToNewTab)
888892
{
@@ -1134,20 +1138,21 @@ void UpdateSelectedItem()
11341138
var listView = m_listView;
11351139
if (listView != null)
11361140
{
1137-
var tvi = SelectedItem as TabViewItem;
1138-
if (tvi == null)
1139-
{
1140-
tvi = ContainerFromItem(SelectedItem) as TabViewItem;
1141-
}
1142-
1143-
if (tvi != null)
1144-
{
1145-
listView.SelectedItem = tvi;
1146-
1147-
// Setting ListView.SelectedItem will not work here in all cases.
1148-
// The reason why that doesn't work but this does is unknown.
1149-
tvi.IsSelected = true;
1150-
}
1141+
listView.SelectedItem = SelectedItem;
1142+
//var tvi = SelectedItem as TabViewItem;
1143+
//if (tvi == null)
1144+
//{
1145+
// tvi = ContainerFromItem(SelectedItem) as TabViewItem;
1146+
//}
1147+
1148+
//if (tvi != null)
1149+
//{
1150+
// listView.SelectedItem = tvi;
1151+
1152+
// // Setting ListView.SelectedItem will not work here in all cases.
1153+
// // The reason why that doesn't work but this does is unknown.
1154+
// tvi.IsSelected = true;
1155+
//}
11511156
}
11521157
}
11531158

0 commit comments

Comments
 (0)