comparison MetroWpf/MetroWpf.Xaml/Transitions/Fade.cs @ 24:a8b50a087544

Stocks and FxRates working, new menu introduced. Working nicely so far
author adminsh@apollo
date Tue, 20 Mar 2012 20:18:35 +0000
parents
children
comparison
equal deleted inserted replaced
23:399398841fd0 24:a8b50a087544
1 using System.Windows;
2 using System.Windows.Controls;
3 using System.Windows.Media.Animation;
4
5 namespace MetroWpf.Xaml.Transitions
6 {
7 // Simple transition that fades out the old content
8 public class FadeTransition : Transition
9 {
10 static FadeTransition()
11 {
12 IsNewContentTopmostProperty.OverrideMetadata(typeof(FadeTransition), new FrameworkPropertyMetadata(false));
13 }
14
15 public Duration Duration
16 {
17 get { return (Duration)GetValue(DurationProperty); }
18 set { SetValue(DurationProperty, value); }
19 }
20
21 public static readonly DependencyProperty DurationProperty =
22 DependencyProperty.Register("Duration", typeof(Duration), typeof(FadeTransition), new UIPropertyMetadata(Duration.Automatic));
23
24 protected internal override void BeginTransition(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent)
25 {
26 DoubleAnimation da = new DoubleAnimation(0, Duration);
27 da.Completed += delegate
28 {
29 EndTransition(transitionElement, oldContent, newContent);
30 };
31 oldContent.BeginAnimation(UIElement.OpacityProperty, da);
32 }
33
34 protected override void OnTransitionEnded(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent)
35 {
36 oldContent.BeginAnimation(UIElement.OpacityProperty, null);
37 }
38 }
39 }