Skip to content
Draft
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,71 @@ public async Task When_Empty_Storyboard_Paused()
Assert.AreEqual(ClockState.Active, storyboard.GetCurrentState());
await TestServices.WindowHelper.WaitFor(() => completed);
}

[TestMethod]
public async Task When_DependentAnimation_Without_EnableDependentAnimation_Completes()
{
var border = new Microsoft.UI.Xaml.Controls.Border
{
Width = 100,
Height = 100
};

var animation = new DoubleAnimation
{
From = 100,
To = 200,
Duration = new Duration(System.TimeSpan.FromMilliseconds(100)),
EnableDependentAnimation = false // Explicitly set to false
};

Storyboard.SetTarget(animation, border);
Storyboard.SetTargetProperty(animation, "Height");

var storyboard = new Storyboard();
storyboard.Children.Add(animation);

bool completed = false;
storyboard.Completed += (s, e) => completed = true;

storyboard.Begin();

// The Completed event should fire even though the animation doesn't actually run
await TestServices.WindowHelper.WaitFor(() => completed, timeoutMS: 2000);
Assert.IsTrue(completed, "Storyboard.Completed should fire even for dependent animations without EnableDependentAnimation");
}

[TestMethod]
public async Task When_DependentAnimation_Stopped_Before_Completion()
{
var border = new Microsoft.UI.Xaml.Controls.Border
{
Width = 100,
Height = 100
};

var animation = new DoubleAnimation
{
From = 100,
To = 200,
Duration = new Duration(System.TimeSpan.FromMilliseconds(100)),
EnableDependentAnimation = false
};

Storyboard.SetTarget(animation, border);
Storyboard.SetTargetProperty(animation, "Height");

var storyboard = new Storyboard();
storyboard.Children.Add(animation);

bool completed = false;
storyboard.Completed += (s, e) => completed = true;

storyboard.Begin();
storyboard.Stop(); // Stop immediately

// Completed should not fire when stopped before completion
await TestServices.WindowHelper.WaitForIdle();
Assert.IsFalse(completed, "Storyboard.Completed should not fire when stopped before completion");
}
}
11 changes: 11 additions & 0 deletions src/Uno.UI/UI/Xaml/Media/Animation/ColorAnimationUsingKeyFrames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,17 @@

if (!EnableDependentAnimation && this.GetIsDependantAnimation())
{ // Don't start the animator its a dependent animation
// However, we still need to complete the animation to maintain consistency with WinUI

Check failure on line 247 in src/Uno.UI/UI/Xaml/Media/Animation/ColorAnimationUsingKeyFrames.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 247 in src/Uno.UI/UI/Xaml/Media/Animation/ColorAnimationUsingKeyFrames.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 247 in src/Uno.UI/UI/Xaml/Media/Animation/ColorAnimationUsingKeyFrames.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 247 in src/Uno.UI/UI/Xaml/Media/Animation/ColorAnimationUsingKeyFrames.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)
State = TimelineState.Active;
_ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
if (State == TimelineState.Stopped)
{
// If the animation was force-stopped, don't trigger completion
return;
}
OnEnd();
});
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,17 @@

if (!EnableDependentAnimation && this.GetIsDependantAnimation())
{ // Don't start the animator its a dependent animation
// However, we still need to complete the animation to maintain consistency with WinUI

Check failure on line 217 in src/Uno.UI/UI/Xaml/Media/Animation/DoubleAnimationUsingKeyFrames.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 217 in src/Uno.UI/UI/Xaml/Media/Animation/DoubleAnimationUsingKeyFrames.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 217 in src/Uno.UI/UI/Xaml/Media/Animation/DoubleAnimationUsingKeyFrames.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)
State = TimelineState.Active;
_ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
if (State == TimelineState.Stopped)
{
// If the animation was force-stopped, don't trigger completion
return;
}
OnEnd();
});
return;
}

Expand Down
11 changes: 11 additions & 0 deletions src/Uno.UI/UI/Xaml/Media/Animation/Timeline.animation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,17 @@

if (!EnableDependentAnimation && _owner.GetIsDependantAnimation())
{ // Don't start the animator its a dependent animation
// However, we still need to complete the animation to maintain consistency with WinUI

Check failure on line 287 in src/Uno.UI/UI/Xaml/Media/Animation/Timeline.animation.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 287 in src/Uno.UI/UI/Xaml/Media/Animation/Timeline.animation.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 287 in src/Uno.UI/UI/Xaml/Media/Animation/Timeline.animation.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)
State = TimelineState.Active;
_ = _owner.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
if (State == TimelineState.Stopped)
{
// If the animation was force-stopped, don't trigger completion
return;
}
OnEnd();
});
return;
}

Expand Down
Loading