Skip to content

Commit

Permalink
chore: Ensure proper check for template root
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Feb 24, 2025
1 parent a2c40bf commit ba29652
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Uno.UI/UI/Xaml/Controls/ScrollBar/ScrollBar.uno.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,17 @@ private static void DetachEvents(object snd, RoutedEventArgs args) // OnUnloaded

internal bool HasFixedVisualStates()
{
#if __SKIA__
return false;
#else
if (this.GetTemplateRoot() is not { } templateRoot)
{
return false;
}

if (_hasFixedVisualStates is null)
{
var groups = VisualStateManager.GetVisualStateGroups(this.GetTemplateRoot());
var groups = VisualStateManager.GetVisualStateGroups(templateRoot);
if (groups.FirstOrDefault(g => g.Name == "CommonStates") is { } commonStates)
{
_hasFixedVisualStates = commonStates.States?.Any(s => s.Name == "Vertical_Normal") ?? false;
Expand All @@ -56,6 +64,7 @@ internal bool HasFixedVisualStates()
}

return _hasFixedVisualStates.Value;
#endif
}

#if !UNO_HAS_ENHANCED_LIFECYCLE
Expand Down

0 comments on commit ba29652

Please sign in to comment.