Permalink
Cannot retrieve contributors at this time
Fetching contributors…
| using System; | |
| using System.Windows; | |
| using System.Windows.Controls; | |
| using System.Windows.Shapes; | |
| using System.Windows.Media; | |
| using System.Windows.Media.Animation; | |
| namespace SDKSample | |
| { | |
| public class FillBehaviorExample : Page | |
| { | |
| private Storyboard myStoryboard; | |
| public FillBehaviorExample() | |
| { | |
| NameScope.SetNameScope(this, new NameScope()); | |
| this.WindowTitle = "Fading Rectangle Example"; | |
| StackPanel myPanel = new StackPanel(); | |
| myPanel.Margin = new Thickness(10); | |
| Rectangle myRectangle = new Rectangle(); | |
| myRectangle.Name = "myRectangle"; | |
| this.RegisterName(myRectangle.Name, myRectangle); | |
| myRectangle.Width = 100; | |
| myRectangle.Height = 100; | |
| myRectangle.Fill = Brushes.Blue; | |
| // <SnippetFillBehaviorExampleRectangleInline> | |
| DoubleAnimation myDoubleAnimation = new DoubleAnimation(); | |
| myDoubleAnimation.From = 1.0; | |
| myDoubleAnimation.To = 0.0; | |
| myDoubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(5)); | |
| // </SnippetFillBehaviorExampleRectangleInline> | |
| myStoryboard = new Storyboard(); | |
| myStoryboard.Children.Add(myDoubleAnimation); | |
| Storyboard.SetTargetName(myDoubleAnimation, myRectangle.Name); | |
| Storyboard.SetTargetProperty(myDoubleAnimation, new PropertyPath(Rectangle.OpacityProperty)); | |
| // Use the Loaded event to start the Storyboard. | |
| myRectangle.Loaded += new RoutedEventHandler(myRectangleLoaded); | |
| myPanel.Children.Add(myRectangle); | |
| this.Content = myPanel; | |
| } | |
| private void myRectangleLoaded(object sender, RoutedEventArgs e) | |
| { | |
| myStoryboard.Begin(this); | |
| } | |
| } | |
| } |