Open matizk144 opened 3 years ago
Thanks for the report!
This may be an issue related to the handling of IsSelected
in Selector
.
I have been looking at this, and I think I found the root cause, which may be affecting other controls (even user custom controls may be affected):
To explain what I'm suspecting to be the issue, I'll take a simple example.
Just add a button to a new empty project, and in MainPage
constructor after InitializeComponent
call, add var x = VisualTreeHelper.GetChild(btn, 0);
Note the variable x
value using the debugger on both Android and UWP.
ContentPresenter
(the template root).Back to the PivotHeaderItem
, when the control isn't loaded and GoToState is called, the CurrentState will change and be stored as "Selected". But the control isn't loaded and no visual changes occurred.
After a while, when the PivotHeaderItem
is loaded, GoToState
gets called again with the same state ("Selected"
). This time, VisualStateManager will do nothing because the current state is the same as the requested new state. So it simply returns.
A workaround that's likely to work is to return in VisualStateManager.GoToState if control.IsLoaded is false.
NOTE: This could be the root cause of few other issues related to visual states.
@davidjohnoliver @jeromelaban @MartinZikmund Does my analysis make sense? Any ideas on how to move forward with the this? If it's going to be complicated, would you be okay with the workaround (I haven't actually tested the workaround - but likely will work)?
This may be an issue related to #3519. That being said, you're saying but the control isn't loaded and no visual changes occurred. did you find the location that prevents this case ?
@jeromelaban I didn't, but I assumed this is expected? Will take another look and see if I can get deeper into how VisualStateManager.GoToState works deeply.
Current behavior
For customized PivotHeaderTemplate during Loading application (control) Selected VIsual state is not triggered (but first tab is selected)
Expected behavior
How to reproduce it (as minimally and precisely as possible)
Workaround
Assign to Loaded event of Pivot control and reselect Items.. e.g:
Nuget Package: Uno.UI.Skia.Gtk: 3.3.0
Nuget Package Version(s):
Affected platform(s):
IDE:
Relevant plugins:
Anything else we need to know?