`TabHeaderItemTemplate` binding context should be the selected selected item, not `TabItem`
Problem
Currently, the implementation of TabView prevents trimming as it requires reflection for any binding that relies on the TabItem.Data property. The implementation of TabView creates instances of TabItem for each item in the ItemsSource.
protected virtual void AddHeaderForItem(object item)
Unfortunately, it is not possible to bind to an object without resorting to reflection based bindings. This means this applications that want to utilize their original ItemsSource item cannot be fully trimmed or AOT.
Solution
The binding context for TabHeaderItemTemplate should be the current Item in the ItemsSource and not an arbitrary library TabItem type. Unfortunately, I don't know what a good solution/replacement for automatically wiring up replacements such as PressedCommand and IsSelected
- Maybe expose a generic
PressedCommandon theTabViewitself which passes theItemthat was pressed - Maybe instead of the triggers being declared on the tabs themselves, they get handled as styles on the
TabView
This changes is also horribly breaking, but the API shape of TabView is not very clean and has many limitations. This should be a goal in that refactor.