Skip to content
Open
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
7 changes: 7 additions & 0 deletions src/SamplesApp/UITests.Shared/UITests.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -5290,6 +5290,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Media_Animation\DoubleAnimation_AutoReverse.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Media_Animation\DoubleAnimation_RenderTransformOrigin.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -8932,6 +8936,9 @@
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Media_Animation\DoubleAnimation_Opacity_TextBlock.xaml.cs">
<DependentUpon>DoubleAnimation_Opacity_TextBlock.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Media_Animation\DoubleAnimation_AutoReverse.xaml.cs">
<DependentUpon>DoubleAnimation_AutoReverse.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Media_Animation\DoubleAnimation_RenderTransformOrigin.xaml.cs">
<DependentUpon>DoubleAnimation_RenderTransformOrigin.xaml</DependentUpon>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<UserControl
x:Class="GenericApp.Views.Content.UITests.Animations.DoubleAnimation_AutoReverse"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="600"
d:DesignWidth="400">

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<StackPanel Grid.Row="0" Orientation="Horizontal" Spacing="10" Margin="10">
<Button x:Name="StartButton" Content="Start" Click="StartAnimation" />
<Button x:Name="StopButton" Content="Stop" Click="StopAnimation" />
</StackPanel>

<TextBlock Grid.Row="1" x:Name="StatusText" Text="Click Start to begin animation" Margin="10" />

<Grid Grid.Row="2" Margin="20">
<Rectangle x:Name="AnimatedRectangle"
Width="50"
Height="50"
Fill="{ThemeResource SystemAccentColorBrush}"
HorizontalAlignment="Left"
VerticalAlignment="Top">
<Rectangle.RenderTransform>
<TranslateTransform x:Name="RectTransform" />
</Rectangle.RenderTransform>
</Rectangle>

<StackPanel VerticalAlignment="Bottom" Margin="10">
<TextBlock Text="AutoReverse=True" FontWeight="Bold" Margin="0,0,0,10" />
<TextBlock Text="Duration: 2 seconds" />
<TextBlock Text="From: 0, To: 300" />
<TextBlock Text="Expected: Move right, then back to start" TextWrapping="Wrap" />
</StackPanel>
</Grid>

<Grid.Resources>
<Storyboard x:Key="MoveStoryboard">
<DoubleAnimation
Storyboard.TargetName="RectTransform"
Storyboard.TargetProperty="X"
From="0"
To="300"
Duration="0:0:2"
AutoReverse="True"
FillBehavior="HoldEnd" />
</Storyboard>
</Grid.Resources>
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media.Animation;
using Uno.UI.Samples.Controls;

namespace GenericApp.Views.Content.UITests.Animations
{
[Sample("Animations", Description = "Demonstrates AutoReverse functionality. The rectangle should move right then back to the start position.")]
public sealed partial class DoubleAnimation_AutoReverse : UserControl
{
private Storyboard _storyboard;

public DoubleAnimation_AutoReverse()
{
this.InitializeComponent();
}

private void StartAnimation(object sender, RoutedEventArgs e)
{
if (_storyboard == null)
{
_storyboard = (Storyboard)Resources["MoveStoryboard"];
_storyboard.Completed += OnStoryboardCompleted;
}

StatusText.Text = "Animation started...";
_storyboard.Begin();
}

private void StopAnimation(object sender, RoutedEventArgs e)
{
_storyboard?.Stop();
StatusText.Text = "Animation stopped";
}

private void OnStoryboardCompleted(object sender, object e)
{
StatusText.Text = "Animation completed - rectangle should be back at start position";
}
}
}
Loading
Loading