TabView SelectedItem Property Doesn't Set IsSelected Property of TabViewItems when ObservableCollection is Used
See original GitHub issueDescribe the bug
Since our TabViewItems’ Content property contains a Frame navigated to content, it turns out it is very expensive to manually create a TabViewItem and add it to TabView.TabItems
, so instead we set the TabItemsSource
property to an ObservableCollection<InstanceTabItem>
to ensure (hopefully) items get disposed of when removed from the collection.
The problem with this approach is that programatically modifying the SelectedItem
property to be set to one of the InstanceTabItems in the collection results in the TabView.SelectionChanged
event NOT firing and the associated TabViewItem not being selected.
Steps to reproduce the bug
Steps to reproduce the behavior:
- Add TabView to project
- Set TabView.TabItemsSource to an ObservableCollection full of data items that will be associated with a TabViewItem
- Attempt to change the TabView.SelectedItem property from code behind to one of the items in the ObservableCollection
Expected behavior Logically, one would expect easy interpretation of tab data items (InstanceTabItem) in place of TabViewItems for the SelectedItem property to be consistent with other properties in the control that exclusively accept data items when an ObservableCollection is in use for the TabItemsSource.
Version Info
NuGet package version: Microsoft.UI.Xaml 2.4.0-prerelease.200113001
Windows 10 version | Saw the problem? |
---|---|
Insider Build (19041.172) | Yes |
November 2019 Update (18363) | |
May 2019 Update (18362) | |
October 2018 Update (17763) | |
April 2018 Update (17134) | |
Fall Creators Update (16299) | |
Creators Update (15063) |
Device form factor | Saw the problem? |
---|---|
Desktop | Yes |
Mobile | |
Xbox | |
Surface Hub | |
IoT |
Additional context This application is using this version of WinUI to work around other bugs, so unless changes were made recently that are relevant to this issue, it wouldn’t make sense to upgrade/downgrade it as a troubleshooting step.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (6 by maintainers)
I’ll reopen this if the issue occurs again.
@chingucoding Yes. I’ll give this a try when I get another chance