uno.toolkit.ui
uno.toolkit.ui copied to clipboard
[Windows][TabBar] SelectedIndex doesn't update selected item visual state
Current behavior
On Windows, we need to set SelectedIndex
as a TwoWay
binding if we want the selected item visual state to update.
Expected behavior
On Windows, we should not need to set SelectedIndex
as a TwoWay
binding if we want the selected item visual state to update.
Please note that I know that if we don't set SelectedIndex
as a TwoWay
binding the selected index property won't be updated since it's an expected behavior.
How to reproduce it (as minimally and precisely as possible)
- Download TabBarSample.zip
- Start on UWP (Would also be able to reproduce on WinUI)
- Click on the buttons
- Notice that the selected index is not updating the item visual state.
Nuget Package: Uno.Toolkit.UI
Package Version(s): 2.6.0-dev.40
Affected platform(s):
- [ ] WebAssembly
- [ ] Android
- [ ] iOS
- [ ] macOS (AppKit)
- [ ] Mac Catalyst
- [ ] Skia
- [ ] WPF
- [ ] GTK (Linux)
- [ ] Linux Framebuffer
- [ ] Tizen
- [x] Windows
IDE:
- [x] Visual Studio 2022
- [ ] Visual Studio 2019
- [ ] Visual Studio Code
- [ ] Visual Studio for Mac
- [ ] Rider Windows
- [ ] Rider macOS
Relevant plugins:
Anything else we need to know?
I took a look at this. Something very weird is going on on UWP.
First, the PropertyChanged event is subscribed twice (one for the TextBlock.Text binding, the other for TabBar.SelectedIndex binding)
Then, out of sudden, UWP decides to unsubscribe the event for TabBar.SelectedIndex.
I don't see why UWP should unsubscribe when TabBar.SelectedIndex setter is called.
@Xiaoy312 Do you have any idea?
Note to save time if someone will look: The project crashed for me with unrelated error, and solved by removing <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
in App.xaml.
Oh it quite makes sense now. When the property is set explicitly, all OneWay bindings are cleared.
@Youssef1313, so this is a bug in TabBar then right? Not a binding thing in the sample?
@kazo0 The sample looks fine to me. I think yes it's a TabBar bug.
It affects Windows but not Uno targets because Uno doesn't remove the binding (which looks like another bug in Uno)
@Youssef1313 @Xiaoy312 quick question, I tried Uno.Toolkit.UI 3.0.5 and 3.1.0-dev.33 on the sample provided and the behavior is the same as described. Am I testing the right versions? Was the fix merge into Uno.Toolkit.UI 4.0.0-dev?
Got the same issue yesterday with uno 4.10.13