question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TabView SelectedItem Property Doesn't Set IsSelected Property of TabViewItems when ObservableCollection is Used

See original GitHub issue

Describe 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:

  1. Add TabView to project
  2. Set TabView.TabItemsSource to an ObservableCollection full of data items that will be associated with a TabViewItem
  3. 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
lukeblevinscommented, May 6, 2020

I’ll reopen this if the issue occurs again.

1reaction
lukeblevinscommented, May 6, 2020

@chingucoding Yes. I’ll give this a try when I get another chance

Read more comments on GitHub >

github_iconTop Results From Across the Web

SelectedItem change is not reflected in TabView UI after ...
When item is added to TabItemsSource collection and SelectedItem is changed to this newly added item, TabView UI does not reflect this ( ......
Read more >
When setting the second TabItem IsSelected property of ...
I have reproduced the issue and changed the item status to "Unplanned". Workaround: Use TabView SelectedItem or SelectedIndex properties. // ...
Read more >
Tab control not selecting first item in observable collection ...
I notice that the TabControl that has its ItemsSource property bound to an ObservableCollection does not select the first item in the collection ......
Read more >
Xamarin Community Toolkit TabView
Property that reflects the current tab items. TabItemsSource, IList, A collection used to generate the TabView's tab items. TabStripPlacement ...
Read more >
TabView - Windows Community Toolkit
TabView is a control for displaying a set of tabs and their content.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found