Skip to content

Commit 20b4af1

Browse files
committed
fix: TabView does not render item content with bindings
- Workaround for #4894 in TabView - sets the ContentPresenter's DataContext so that it matches the DataContext of the TabViewItem.
1 parent b4fdc9c commit 20b4af1

File tree

1 file changed

+7
-0
lines changed
  • src/Uno.UI/Microsoft/UI/Xaml/Controls/TabView

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,13 @@ void OnTabContentPresenterLosingFocus(object sender, LosingFocusEventArgs args)
869869

870870
tabContentPresenter.LosingFocus += OnTabContentPresenterLosingFocus;
871871

872+
#if IS_UNO
873+
// TODO: Uno specific - issue #4894 - in UWP the ContentPresenter does not become
874+
// the parent of the Content. In Uno it does, so we need to make sure
875+
// the inherited DataContext will match the TabViewItem.
876+
tabContentPresenter.DataContext = tvi.DataContext;
877+
#endif
878+
872879
tabContentPresenter.Content = tvi.Content;
873880
tabContentPresenter.ContentTemplate = tvi.ContentTemplate;
874881
tabContentPresenter.ContentTemplateSelector = tvi.ContentTemplateSelector;

0 commit comments

Comments
 (0)