* Add failing tests for #18280 and #20845
Tests cover:
- TabItem child DataContext binding not resolving (#20845)
- DataContext binding not propagating to TabItem children (#20845)
- DataContext binding not surviving tab switch round-trip (#20845)
- UserControl content losing DataContext on tab switch (#18280)
- Content temporarily getting wrong DataContext when switching tabs
- Transition not applying new DataContext to old content
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix TabControl DataContext issues (#18280, #20845)
Add ContentPresenter.SetContentWithDataContext to atomically set Content
and DataContext, preventing the intermediate state where setting Content
to a Control clears DataContext and causes the content to briefly inherit
the wrong DataContext from higher up the tree.
TabControl.UpdateSelectedContent now uses this method, and the DataContext
subscription no longer applies the new container's DataContext to the old
content during page transitions.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Add tests for ContentTemplate with Control content DataContext
When a TabItem has a ContentTemplate and its Content is a Control, the
ContentPresenter should set DataContext to the content (so the template
can bind to the control's properties), not the TabItem's DataContext.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Only use SetContentWithDataContext when no ContentTemplate is set
When a ContentTemplate is present and content is a Control, the
ContentPresenter should set DataContext = content so the template can
bind to the control's properties. Only override DataContext with the
container's DataContext when there's no template (i.e. the presenter
displays the control directly).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>