0
当鼠标在按钮上时,我有以下xaml用于更改WPF按钮的图像。它给出下面的错误。任何帮助表示赞赏...WPF按钮故事板与MouseOver图像
“System.Windows.Media.Animation.DoubleAnimation”动画对象不能用于动画属性“来源”,因为它是不兼容的类型“System.Windows.Media.ImageSource”的。
<Style TargetType="{x:Type local:ButtonControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:ButtonControl}">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="MouseOver">
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="img"
Storyboard.TargetProperty="Source"
To="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=MouseOverImage}"
/>
</Storyboard>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border>
<Image x:Name="img"
Source="pack://application:,,,/Recipe_06_13;component/Resources/normal.bmp"
/>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>