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