Skip to content

Sample: Animation cancellation — .NET MAUI 11 Preview 5#772

Open
davidortinau wants to merge 1 commit into
dotnet:mainfrom
davidortinau:daortin/p5-sample-animation-cancel
Open

Sample: Animation cancellation — .NET MAUI 11 Preview 5#772
davidortinau wants to merge 1 commit into
dotnet:mainfrom
davidortinau:daortin/p5-sample-animation-cancel

Conversation

@davidortinau

Copy link
Copy Markdown
Contributor

Adds a new sample under 11.0/UserInterface/Animation/AnimationCancellation/ that demonstrates the new CancellationToken support on ViewExtensions animation methods added in .NET MAUI 11 Preview 5 (dotnet/maui#33372).

The new FadeToAsync, RotateToAsync, ScaleToAsync, TranslateToAsync, and their Rel* / *X / *Y siblings accept a CancellationToken and return Task<bool>true when the animation was canceled, false when it ran to completion. They do not throw on cancellation.

The non-token-based methods (FadeTo, RotateTo, etc.) are now [Obsolete] in favor of the new async overloads.

What the sample shows

  • Image.FadeToAsync(0, 5000, Easing.SinIn, token) driven by a CancellationTokenSource
  • Inspecting the Task<bool> return value to distinguish cancellation from natural completion
  • Cancel and Reset buttons wired to the same CancellationTokenSource

Note

11.0/Directory.Build.props pin to Preview 3 applies here too — see the BoxView.Fill PR description.

Demonstrates the new CancellationToken support on ViewExtensions
animation methods added in .NET MAUI 11 (dotnet/maui#33372).

Includes:
- FadeToAsync with a CancellationTokenSource
- Inspecting the Task<bool> return value to distinguish cancellation
  from natural completion (the new overloads do not throw on cancel)
- docregions for inclusion in docs/user-interface/animation/basic.md

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant