From ccd558d749332bfdbca825fe212b5c125f7dbee6 Mon Sep 17 00:00:00 2001 From: David Ortinau Date: Sun, 7 Jun 2026 07:08:25 -0500 Subject: [PATCH] =?UTF-8?q?Sample:=20Animation=20cancellation=20=E2=80=94?= =?UTF-8?q?=20.NET=20MAUI=2011=20Preview=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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> --- .../AnimationCancellation.sln | 26 + .../AnimationCancellation.csproj | 59 +++ .../AnimationCancellation/App.xaml | 14 + .../AnimationCancellation/App.xaml.cs | 17 + .../AnimationCancellation/GlobalUsings.cs | 3 + .../AnimationCancellation/MainPage.xaml | 74 +++ .../AnimationCancellation/MainPage.xaml.cs | 47 ++ .../AnimationCancellation/MauiProgram.cs | 24 + .../Platforms/Android/AndroidManifest.xml | 6 + .../Platforms/Android/MainActivity.cs | 11 + .../Platforms/Android/MainApplication.cs | 16 + .../Android/Resources/values/colors.xml | 6 + .../Platforms/MacCatalyst/AppDelegate.cs | 10 + .../Platforms/MacCatalyst/Entitlements.plist | 10 + .../Platforms/MacCatalyst/Info.plist | 29 ++ .../Platforms/MacCatalyst/Program.cs | 13 + .../Platforms/Windows/App.xaml | 8 + .../Platforms/Windows/App.xaml.cs | 24 + .../Platforms/Windows/Package.appxmanifest | 43 ++ .../Platforms/Windows/app.manifest | 15 + .../Platforms/iOS/AppDelegate.cs | 10 + .../Platforms/iOS/Info.plist | 32 ++ .../Platforms/iOS/Program.cs | 13 + .../iOS/Resources/PrivacyInfo.xcprivacy | 51 ++ .../Resources/AppIcon/appicon.svg | 4 + .../Resources/AppIcon/appiconfg.svg | 8 + .../Resources/Fonts/OpenSans-Regular.ttf | Bin 0 -> 107280 bytes .../Resources/Fonts/OpenSans-Semibold.ttf | Bin 0 -> 111188 bytes .../Resources/Images/dotnet_bot.png | Bin 0 -> 93437 bytes .../Resources/Splash/splash.svg | 8 + .../Resources/Styles/Colors.xaml | 45 ++ .../Resources/Styles/Styles.xaml | 451 ++++++++++++++++++ .../Animation/AnimationCancellation/README.md | 48 ++ 33 files changed, 1125 insertions(+) create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation.sln create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/AnimationCancellation.csproj create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/App.xaml create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/App.xaml.cs create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/GlobalUsings.cs create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/MainPage.xaml create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/MainPage.xaml.cs create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/MauiProgram.cs create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/Platforms/Android/AndroidManifest.xml create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/Platforms/Android/MainActivity.cs create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/Platforms/Android/MainApplication.cs create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/Platforms/Android/Resources/values/colors.xml create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/Platforms/MacCatalyst/AppDelegate.cs create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/Platforms/MacCatalyst/Entitlements.plist create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/Platforms/MacCatalyst/Info.plist create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/Platforms/MacCatalyst/Program.cs create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/Platforms/Windows/App.xaml create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/Platforms/Windows/App.xaml.cs create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/Platforms/Windows/Package.appxmanifest create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/Platforms/Windows/app.manifest create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/Platforms/iOS/AppDelegate.cs create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/Platforms/iOS/Info.plist create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/Platforms/iOS/Program.cs create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/Platforms/iOS/Resources/PrivacyInfo.xcprivacy create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/Resources/AppIcon/appicon.svg create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/Resources/AppIcon/appiconfg.svg create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/Resources/Fonts/OpenSans-Regular.ttf create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/Resources/Fonts/OpenSans-Semibold.ttf create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/Resources/Images/dotnet_bot.png create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/Resources/Splash/splash.svg create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/Resources/Styles/Colors.xaml create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/Resources/Styles/Styles.xaml create mode 100644 11.0/UserInterface/Animation/AnimationCancellation/README.md diff --git a/11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation.sln b/11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation.sln new file mode 100644 index 000000000..ad94cb26c --- /dev/null +++ b/11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation.sln @@ -0,0 +1,26 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.0.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AnimationCancellation", "AnimationCancellation\AnimationCancellation.csproj", "{4AE8913C-E1C9-4E9E-B410-3C034ABE6EFB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4AE8913C-E1C9-4E9E-B410-3C034ABE6EFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4AE8913C-E1C9-4E9E-B410-3C034ABE6EFB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4AE8913C-E1C9-4E9E-B410-3C034ABE6EFB}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {4AE8913C-E1C9-4E9E-B410-3C034ABE6EFB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4AE8913C-E1C9-4E9E-B410-3C034ABE6EFB}.Release|Any CPU.Build.0 = Release|Any CPU + {4AE8913C-E1C9-4E9E-B410-3C034ABE6EFB}.Release|Any CPU.Deploy.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {DCD6A0DD-E16D-4518-9EAF-E3DD9CB9A645} + EndGlobalSection +EndGlobal diff --git a/11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/AnimationCancellation.csproj b/11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/AnimationCancellation.csproj new file mode 100644 index 000000000..2ce7f8a69 --- /dev/null +++ b/11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/AnimationCancellation.csproj @@ -0,0 +1,59 @@ + + + + net11.0-android;net11.0-ios;net11.0-maccatalyst + $(TargetFrameworks);net11.0-windows10.0.19041.0 + + Exe + AnimationCancellation + true + true + enable + enable + + true + + + AnimationCancellation + + + com.companyname.animationcancellation + + + 1.0 + 1 + + None + + 15.0 + 17.0 + 24.0 + 10.0.17763.0 + 10.0.17763.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/App.xaml b/11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/App.xaml new file mode 100644 index 000000000..e26f6f210 --- /dev/null +++ b/11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/App.xaml @@ -0,0 +1,14 @@ + + + + + + + + + + + diff --git a/11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/App.xaml.cs b/11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/App.xaml.cs new file mode 100644 index 000000000..bc13347f2 --- /dev/null +++ b/11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/App.xaml.cs @@ -0,0 +1,17 @@ +namespace AnimationCancellation; + +public partial class App : Application +{ + public App() + { + InitializeComponent(); + } + + protected override Window CreateWindow(IActivationState? activationState) + { + return new Window(new MainPage()) + { + Title = "Animation Cancellation - .NET MAUI 11" + }; + } +} diff --git a/11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/GlobalUsings.cs b/11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/GlobalUsings.cs new file mode 100644 index 000000000..e78d112ed --- /dev/null +++ b/11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/GlobalUsings.cs @@ -0,0 +1,3 @@ +global using Microsoft.Maui.Controls; +global using Microsoft.Maui.Controls.Xaml; +global using Microsoft.Maui.Controls.Shapes; diff --git a/11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/MainPage.xaml b/11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/MainPage.xaml new file mode 100644 index 000000000..48fce7bbb --- /dev/null +++ b/11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/MainPage.xaml @@ -0,0 +1,74 @@ + + + + + + +