uno.toolkit.ui icon indicating copy to clipboard operation
uno.toolkit.ui copied to clipboard

[Windows][TabBar] SelectedIndex doesn't update selected item visual state

Open Soap-141 opened this issue 1 year ago • 7 comments

Current behavior

On Windows, we need to set SelectedIndex as a TwoWay binding if we want the selected item visual state to update.

Animation_90

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.

Animation_91

How to reproduce it (as minimally and precisely as possible)

  1. Download TabBarSample.zip
  2. Start on UWP (Would also be able to reproduce on WinUI)
  3. Click on the buttons
  4. 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?

Soap-141 avatar May 04 '23 19:05 Soap-141

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.

image

I don't see why UWP should unsubscribe when TabBar.SelectedIndex setter is called.

@Xiaoy312 Do you have any idea?

Youssef1313 avatar May 09 '23 21:05 Youssef1313

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.

Youssef1313 avatar May 09 '23 21:05 Youssef1313

Oh it quite makes sense now. When the property is set explicitly, all OneWay bindings are cleared.

Youssef1313 avatar May 09 '23 22:05 Youssef1313

@Youssef1313, so this is a bug in TabBar then right? Not a binding thing in the sample?

kazo0 avatar May 10 '23 13:05 kazo0

@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 avatar May 10 '23 14:05 Youssef1313

@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?

Guidemarcus avatar Jul 31 '23 16:07 Guidemarcus

Got the same issue yesterday with uno 4.10.13

Lee31416 avatar Apr 11 '24 13:04 Lee31416