I have an issue with my ImplicitAnimation. When the grid goes up, everything looks fine, but when the method CloseButton_Click is going and the grid goes down, artefacts like those in the image Artefacts. Does anyone know how to fix it? I'll be grateful for every single idea.
My code looks like this:
public sealed partial class AddTaskView : UserControl
{
private Compositor _compositor;
private Visual myWindow;
private Vector3KeyFrameAnimation offsetAnimation;
private ImplicitAnimationCollection implicitAnimation;
public AddTaskView()
{
this.InitializeComponent();
this.InitializeTransition();
}
private void InitializeTransition()
{
WindowGrid.Height = ((Frame)Window.Current.Content).ActualHeight;
WindowGrid.Width = ((Frame)Window.Current.Content).ActualWidth;
myWindow = ElementCompositionPreview.GetElementVisual(myWindowGrid);
_compositor = myWindow.Compositor;
myWindow.Size = new Vector2((float)((Frame)Window.Current.Content).ActualWidth
, (float)((Frame)Window.Current.Content).ActualHeight);
}
private void ColorSlideTransitionCompleted(object sender, EventArgs e)
{
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
myWindow.Size = new Vector2((float)((Frame)Window.Current.Content).ActualWidth
, (float)((Frame)Window.Current.Content).ActualHeight);
myWindow.Offset = new Vector3(0.0f, (float)WindowGrid.ActualHeight, 0.0f);
offsetAnimation = _compositor.CreateVector3KeyFrameAnimation();
offsetAnimation.Target = nameof(Visual.Offset);
offsetAnimation.InsertExpressionKeyFrame(1.0f, "this.FinalValue");
offsetAnimation.Duration = TimeSpan.FromMilliseconds(5000);
implicitAnimation = _compositor.CreateImplicitAnimationCollection();
implicitAnimation[nameof(Visual.Offset)] = offsetAnimation;
myWindow.ImplicitAnimations = implicitAnimation;
#region slide
myWindow.Offset = new Vector3(0.0f, 0.0f, 0.0f);
#endregion
}
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
myWindow.Offset = new Vector3(0.0f, (float)((Frame)Window.Current.Content).ActualHeight, 0.0f);
}
}
OffTopic: later, I want to connect this animation with a GaussianBlurEffect. Is it possible to do it? Do you have any tips for me? I'll be grateful too.