Hi,
I want to begin a storyboard, every time my Image source changes. I have implemented INotifyPropertyChanged.
Can anyone help me achieve this?
Thanks,
<Image Name="pic" HorizontalAlignment="Center" VerticalAlignment="Center" Source="{Binding ElementName=uc, Path=Image}">
<Image.Resources>
<Storyboard x:Key="picStory" x:Name="picStory">
<DoubleAnimation
Storyboard.TargetProperty="(Image.RenderTransform).(TransformGroup.Children)[0].(RotateTransform.Angle)"
From="0" To="20" Duration="0:0:0.7" />
<DoubleAnimation Storyboard.TargetProperty="(Image.RenderTransform).(TransformGroup.Children)[1].(TranslateTransform.Y)" From="100" To="0" Duration="0:0:0.7" />
</Storyboard>
</Image.Resources>
<Image.Style>
<Style TargetType="{x:Type Image}" BasedOn="{StaticResource {x:Type Image}}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Source}">
<DataTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource picStory}"/>
</DataTrigger.EnterActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
<Image.RenderTransform>
<TransformGroup>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Image.RenderTransform>
</Image>
Code bound to "uc":
private BitmapImage image;
public BitmapImage Image
{
get { return image; }
set
{
image = value;
OnPropertyChanged("Image");
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null) PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
}