Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Ensure proper check for template root #19582

Merged
merged 2 commits into from
Feb 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading