public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); Opacity = 0; FadeIn(); } private void Window_Closing(object sender, CancelEventArgs e) { Closing -= Window_Closing; e.Cancel = true; DoubleAnimation fadeOut = new DoubleAnimation(0, TimeSpan.FromMilliseconds(350)); fadeOut.Completed += (s, _) => Close(); BeginAnimation(OpacityProperty, fadeOut); } private void FadeIn() { DoubleAnimation fadeIn = new DoubleAnimation(1, TimeSpan.FromMilliseconds(250)); DoubleAnimation scaleWidth = new DoubleAnimation(Width * 1.1, TimeSpan.FromMilliseconds(350)); DoubleAnimation scaleHeight = new DoubleAnimation(Height * 1.1, TimeSpan.FromMilliseconds(350)); BeginAnimation(OpacityProperty, fadeIn); BeginAnimation(WidthProperty, scaleWidth); BeginAnimation(HeightProperty, scaleHeight); } } 


Animation follows each other, and how to perform it simultaneously? Tried threads, but cannot access GUI.

  • Do you have WinForms? From the threads you can refer to the GUI, only a little more complicated. But the simple use of threads does not guarantee simultaneous execution. - 4per
  • No, I have WPF - deadmoz5er
  • Show full code - Andrey NOP
  • one
    Hmm, but where did you get that animation goes after each other? There is no point in animating anything before the Loaded event happens - Andrey NOP
  • one
    I rewrote it like this: pastebin.com/Lc0g3Pxc here you can see that the animation goes at the same time, I suspect that the windows are still drawn by the system and the system does not allow changing the properties of the window so quickly, so there are delays and sequential animation is obtained at short intervals. Animation of elements inside the window does not have such problems, because it is performed purely by WPF. You may have to achieve the desired effect "in the old-fashioned way" - with the help of timers. Try it ... - Andrew NOP

0