Skip to content

Commit

Permalink
Merge pull request #19582 from unoplatform/dev/mazi/scrollbar-check
Browse files Browse the repository at this point in the history
fix: Ensure proper check for template root
  • Loading branch information
MartinZikmund authored Feb 27, 2025
2 parents af9fff9 + bbb3462 commit 1418556
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 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 @@ -17,7 +17,9 @@ partial class ScrollBar
[ThreadStatic]
private static Orientation? _fixedOrientation;

#if !__SKIA__
private bool? _hasFixedVisualStates;
#endif

internal static IDisposable MaterializingFixed(Orientation orientation)
{
Expand All @@ -42,9 +44,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 +66,7 @@ internal bool HasFixedVisualStates()
}

return _hasFixedVisualStates.Value;
#endif
}

#if !UNO_HAS_ENHANCED_LIFECYCLE
Expand Down

0 comments on commit 1418556

Please sign in to comment.