Skip to content

Commit

Permalink
fix: TabView does not render item content with bindings
Browse files Browse the repository at this point in the history
- Workaround for #4894 in TabView - sets the ContentPresenter's DataContext so that it matches the DataContext of the TabViewItem.
  • Loading branch information
MartinZikmund committed Jan 19, 2021
1 parent b4fdc9c commit 20b4af1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Uno.UI/Microsoft/UI/Xaml/Controls/TabView/TabView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,13 @@ void OnTabContentPresenterLosingFocus(object sender, LosingFocusEventArgs args)

tabContentPresenter.LosingFocus += OnTabContentPresenterLosingFocus;

#if IS_UNO
// TODO: Uno specific - issue #4894 - in UWP the ContentPresenter does not become
// the parent of the Content. In Uno it does, so we need to make sure
// the inherited DataContext will match the TabViewItem.
tabContentPresenter.DataContext = tvi.DataContext;
#endif

tabContentPresenter.Content = tvi.Content;
tabContentPresenter.ContentTemplate = tvi.ContentTemplate;
tabContentPresenter.ContentTemplateSelector = tvi.ContentTemplateSelector;
Expand Down

0 comments on commit 20b4af1

Please sign in to comment.