使用StoryBoard更改Image的来源

时间:2010-03-24 14:05:24

标签: silverlight expression-blend-3

我想在鼠标悬停的Silverlight混合中使用故事板改变图像的来源:

   <VisualState x:Name="MouseOver">
<Storyboard>
   ---code here--                                           
</Storyboard>
</VisualState>

1 个答案:

答案 0 :(得分:3)

好吧终于解决了它:

在鼠标悬停时,我只是将图像的可见性调整为colapsed并使其他图像的可见性可见。就是这样:))

                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="fillColor">
                                            <SplineDoubleKeyFrame KeyTime="0" Value=".35"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="image">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                    <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                    </ObjectAnimationUsingKeyFrames>

                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="hoverimage">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                    <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                    </ObjectAnimationUsingKeyFrames>                
                                    </Storyboard>
                                </VisualState>