You decide:
Here's what the storyboard would look like in XAML. You can define multiple storyboards, and apply them as you want:
And here's what the code behind would look like:
I'd definately prefer the XAML in this situation, as it's a ton more intuitive. You can always just define more storyboards, and call them up in the code behind using the key name.
David Morton - http://blog.davemorton.net/ - @davidmmorton - ForumsBrowser, a WPF Forums Client
Here's what the storyboard would look like in XAML. You can define multiple storyboards, and apply them as you want:
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300" Loaded="Window_Loaded" ><Window.Resources><Storyboard x:Key="board"><DoubleAnimation Storyboard.TargetName="TransparentStop"
Storyboard.TargetProperty="Offset" By="1" Duration="0:0:2" /><DoubleAnimation Storyboard.TargetName="BlackStop"
Storyboard.TargetProperty="Offset" By="1" Duration="0:0:2"
BeginTime="0:0:0.05" /></Storyboard></Window.Resources><Grid><Image Source="Images/UFO.jpg" /><Image Source="Images/ladder.jpg"><Image.OpacityMask><LinearGradientBrush StartPoint="0,0" EndPoint="1,0"><GradientStop Offset="0" Color="Black" x:Name="BlackStop"/><GradientStop Offset="0" Color="Transparent" x:Name="TransparentStop"/></LinearGradientBrush></Image.OpacityMask></Image></Grid></Window>
And here's what the code behind would look like:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Diagnostics;
using System.Windows.Media.Animation;
namespace WpfApplication1
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
((Storyboard)Resources["board"]).Begin(this);
}
}
}
I'd definately prefer the XAML in this situation, as it's a ton more intuitive. You can always just define more storyboards, and call them up in the code behind using the key name.
David Morton - http://blog.davemorton.net/ - @davidmmorton - ForumsBrowser, a WPF Forums Client