Added sample page demo for reset feature

This commit is contained in:
Sergio Pedri 2021-09-24 17:55:26 +02:00
Родитель f84a747464
Коммит 4612a38f2a
1 изменённых файлов: 15 добавлений и 0 удалений

Просмотреть файл

@ -5,6 +5,7 @@
using System;
using System.Numerics;
using Microsoft.Toolkit.Uwp.UI;
using Microsoft.Toolkit.Uwp.UI.Animations;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Hosting;
@ -18,6 +19,8 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
{
private Random _random = new Random();
private UIElement _element;
private ImplicitAnimationSet _animationSet;
private bool _areAnimationsToggled;
public ImplicitAnimationsPage()
{
@ -28,6 +31,8 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
public void OnXamlRendered(FrameworkElement control)
{
_element = control.FindChild("Element");
_animationSet = Implicit.GetAnimations(_element);
_areAnimationsToggled = true;
}
private void Load()
@ -60,6 +65,16 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
1);
}
});
SampleController.Current.RegisterNewCommand("Toggle animations", (sender, args) =>
{
if (_element != null)
{
Implicit.SetAnimations(_element, _areAnimationsToggled ? null : _animationSet);
_areAnimationsToggled = !_areAnimationsToggled;
}
});
}
}
}