Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- Opacity = 0;
- Loaded += (o,e) => 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.FromSeconds(2));
- DoubleAnimation scaleWidth = new DoubleAnimation(Width, Width * 1.1, TimeSpan.FromSeconds(2));
- DoubleAnimation scaleHeight = new DoubleAnimation(Height, Height * 1.1, TimeSpan.FromSeconds(2));
- BeginAnimation(OpacityProperty, fadeIn);
- BeginAnimation(WidthProperty, scaleWidth);
- BeginAnimation(HeightProperty, scaleHeight);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment