Skip to content

VisualStateGroup.CurrentState changes at the start of GoToState instead of when the VisualTransition completes (differs from WinUI) #26166

Open

Description

@MartinZikmund

GitHub Issue: n/a

Current behavior

VisualStateGroup.CurrentState is updated at the very start of VisualStateManager.GoToState, before a VisualTransition has run. On WinUI the new state only becomes CurrentState once the transition finishes.

Two visible consequences, both with a ProgressBar (its Updating -> Determinate change uses a non-zero VisualTransition):

  1. While the control is Collapsed (so the transition storyboard never completes on WinUI), IsIndeterminate = false leaves WinUI on Indeterminate; Uno reports Determinate.
  2. While visible, reading CurrentState synchronously right after IsIndeterminate = false gives Updating on WinUI, Determinate on Uno.

Expected behavior

Same as WinUI: CurrentState and CurrentStateChanged follow the transition completion. WinUI source (dxaml/xcp/components/vsm):

  • VisualStateManagerActuator::ChangeVisualState calls BeginTransitionToState (only raises CurrentStateChanging), and calls CompleteTransitionToState right away only for a zero-duration transition.
  • For a non-zero transition, CompleteTransitionToState runs from FinishVisualTransition on storyboard completion.
  • StandardVisualStateManagerDataSource::OnCompleteTransitionToState is the only place that calls CVisualStateGroup::SetCurrentVisualState and raises CurrentStateChanged.

Uno: VisualStateGroup.GoToState assigns _current = targetValues; before starting the transition animation (src/Uno.UI/UI/Xaml/VisualStateGroup.cs, GoToState).

How to reproduce it

Runtime test (Uno.UI.RuntimeTests, Skia desktop):

var sut = new ProgressBar { Width = 200, IsIndeterminate = true };
TestServices.WindowHelper.WindowContent = sut;
await TestServices.WindowHelper.WaitForLoaded(sut);
await TestServices.WindowHelper.WaitForIdle();

VisualStateGroup GetGroup() => VisualStateManager.GetVisualStateGroups((FrameworkElement)VisualTreeHelper.GetChild(sut, 0)).Single(g => g.Name == "CommonStates");

sut.Visibility = Visibility.Collapsed;
await TestServices.WindowHelper.WaitForIdle();
sut.IsIndeterminate = false;
await TestServices.WindowHelper.WaitForIdle();
var collapsed = GetGroup().CurrentState?.Name;   // WinUI: "Indeterminate", Uno: "Determinate"

sut.Visibility = Visibility.Visible;
sut.IsIndeterminate = true;
await TestServices.WindowHelper.WaitForIdle();
sut.IsIndeterminate = false;
var right = GetGroup().CurrentState?.Name;       // WinUI: "Updating", Uno: "Determinate"

Uno result (Skia desktop): Expected "Indeterminate" but was "Determinate" for the collapsed read.

Workaround

Don't rely on reading CurrentState synchronously after a state change; wait for CurrentStateChanged.

Works on UWP/WinUI

Yes, the WinUI values above come from a native WinUI runtime probe (same test, WinAppSDK head) and from the WinUI source listed above.

Environment

Uno.UI master 6aaf32516ac, net11.0-desktop (Skia). The Uno side was reproduced at runtime on Skia desktop only; the code path is not platform specific.

NuGet package version

master @ 6aaf325

Affected platforms

Skia (all heads share the code)

IDE

n/a

Relevant plugins

n/a

Anything else we need to know?

Mostly a test-portability issue: tests that read CurrentState right after a change must be excluded on native WinUI today. Fixing it means deferring _current (and CurrentStateChanged) to transition completion, which interacts with interrupted transitions and needs care.

Activity

  1. added
    kind/bug
    triage/untriaged
    area/skia ✏️
    project/animations 🎡
    platform/all
    difficulty/challenging 🤯
    on Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/skia ✏️difficulty/challenging 🤯kind/bugplatform/allproject/animations 🎡triage/untriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions