Ich möchte die gleiche Animation auf alle meine Bilder in meiner Anwendung platzieren, wenn jemand die Maus über sie bewegt. Als Ergebnis habe ich die folgende Art erstellt:Bild von Stil animieren funktioniert nicht
<Style x:Key="test" TargetType="{x:Type Image}">
<Style.Resources>
<Storyboard x:Key="Storyboard1">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)"
Storyboard.Target="{Binding RelativeSource={RelativeSource Self}}">
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="200">
<EasingDoubleKeyFrame.EasingFunction>
<BackEase EasingMode="EaseOut"/>
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Style.Resources>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Trigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource Storyboard1}"/>
</Trigger.EnterActions>
</Trigger>
</Style.Triggers>
</Style>
und auf dem Bild, das ich auf Animieren planen werde ich diesen Stil gelte als:
<Image Style="{StaticResource test}" Name="image1" Source="/PDV;component/images/t.png" Stretch="Uniform" Width="100" />
, wenn ich meine Maus über dieses Bild schwebe ich Ausnahme:
System.InvalidOperationException wurde nicht behandelt Message = Kann nicht belebte '(0)' auf einer unveränderliche Objektinstanz.
Source = PresentationFramework Stacktrace: bei System.Windows.Media.Animation.Storyboard.VerifyPathIsAnimatable (PropertyPath Pfad) bei System.Windows.Media.Animation.Storyboard.ClockTreeWalkRecursive (Clock currentClock, DependencyObject containingObject, INameScope Namescope, DependencyObject Parent, String parentObjectName, PropertyPath parentPropertyPath, HandoffBehavior HandoffBehavior, Hybriddictionary clockMappings, Int64 Schicht) bei System.Windows.Media.Animation.Storyboard.ClockTreeWalkRecursive (Clock currentClock, DependencyObject containingObject, INameScope Namescope, DependencyObject parentObjec t, String parentObjectName, PropertyPath parentPropertyPath, HandoffBehavior HandoffBehavior, Hybriddictionaryetc ..
Was muss ich, um den Stil zu ändern, damit es funktioniert?