<ScrollView>
<VerticalStackLayout
Padding="30,0"
Spacing="25">
<Image
x:Name="imBot"
Source="dotnet_bot.png"
HeightRequest="185"
Aspect="AspectFit"
SemanticProperties.Description="dot net bot in a race car number eight" />
<Label
x:Name="lbHelloWorld"
Text="Hello, World!"
Style="{StaticResource Headline}"
SemanticProperties.HeadingLevel="Level1" />
<Label
Text="Welcome to the BUG ridden .NET Multi-platform App UI)"
Style="{StaticResource SubHeadline}"
SemanticProperties.HeadingLevel="Level2"
SemanticProperties.Description="Welcome to buggy as hell dot net Multi platform App U I" />
<Button
x:Name="CounterBtn"
Text="Click me to stop the animation"
SemanticProperties.Hint="Counts the number of times you click"
Clicked="OnCounterClicked"
HorizontalOptions="Fill" />
</VerticalStackLayout>
</ScrollView>
REPLACE MAINPAGE.CS WITH:
namespace BugCancelAnimations
{
public partial class MainPage : ContentPage
{
private Random rnd = new Random();
public MainPage()
{
InitializeComponent();
AnimateImage(imBot);
}
private void OnCounterClicked(object sender, EventArgs e)
{
MainThread.BeginInvokeOnMainThread(() => {
lbHelloWorld.Text = "Trying to stop the image animation, but failing!";
Microsoft.Maui.Controls.ViewExtensions.CancelAnimations(imBot);
});
}
private void AnimateImage(Image image)
{
double startY = image.TranslationY;
double range = rnd.Next(6, 8); // Random range between 6 and 16 pixels
double phaseShift = rnd.NextDouble() * 2 * Math.PI; // Random phase shift between 0 and 2π
// Define a continuous, smooth animation using a sinusoidal function with a phase shift
var animation = new Animation(
callback: v => image.TranslationY = startY + (range * Math.Sin(2 * Math.PI * v + phaseShift)),
start: 0,
end: 1,
easing: Easing.Linear);
// Commit the animation to run continuously
animation.Commit(
owner: image,
name: "UpDownAnimation",
rate: 16,
length: 4000, // duration of one full cycle in milliseconds
repeat: () => true); // repeat indefinitely
}
}
}
Build/Run and Deploy, the standard Maui bot image will move up down (animate), click the button to stop the animation and it does nothing.
Installed Workload Id Manifest Version Installation Source
android 34.0.52/8.0.100 VS 17.9.34723.18
maui-windows 8.0.7/8.0.100 VS 17.9.34723.18
maccatalyst 17.2.8004/8.0.100 VS 17.9.34723.18
ios 17.2.8004/8.0.100 VS 17.9.34723.18
Link to public reproduction project repository
No response
Version with bug
Unknown/Other
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
iOS, Android, Windows
Affected platform versions
i.OS 17.4.1 Android 14 Windows 11 Pro 23H2
Did you find any workaround?
No and as a games developer I need this resolved urgently.
Description
The call to: Microsoft.Maui.Controls.ViewExtensions.CancelAnimations([yourImageElement]); does not cancel the animation.
Steps to Reproduce
Create a new project called: BugCancelAnimations
REPLACE MAINPAGE.XAML WITH:
<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="BugCancelAnimations.MainPage">
REPLACE MAINPAGE.CS WITH: namespace BugCancelAnimations { public partial class MainPage : ContentPage {
}
Build/Run and Deploy, the standard Maui bot image will move up down (animate), click the button to stop the animation and it does nothing.
Installed Workload Id Manifest Version Installation Source
android 34.0.52/8.0.100 VS 17.9.34723.18 maui-windows 8.0.7/8.0.100 VS 17.9.34723.18 maccatalyst 17.2.8004/8.0.100 VS 17.9.34723.18 ios 17.2.8004/8.0.100 VS 17.9.34723.18
Link to public reproduction project repository
No response
Version with bug
Unknown/Other
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
iOS, Android, Windows
Affected platform versions
i.OS 17.4.1 Android 14 Windows 11 Pro 23H2
Did you find any workaround?
No and as a games developer I need this resolved urgently.
Relevant log output
No response