1

I want to implement an effect like this:
there is a 80*80 scrollview,and i put a 160*80 pic in it
1s:the pic left/up in the scrollview,2s:the pic right/up in the scrollview
rolling as a transition process

my code:
xaml

    <UserControl.Resources>
    <Storyboard x:Name="Storyboard1">
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="my_combo_pic">
            <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
            <EasingDoubleKeyFrame KeyTime="0:0:3" Value="80"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="my_combo_pic">
            <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
            <EasingDoubleKeyFrame KeyTime="0:0:3" Value="0"/>
        </DoubleAnimationUsingKeyFrames>
    </Storyboard>
</UserControl.Resources>


...
                <ScrollViewer x:Name="my_combo" Tap="MyCombolIconTapped" HorizontalAlignment="Right" Height="80" Margin="0" VerticalAlignment="Bottom" Width="80">
                    <Image x:Name="my_combo_pic" Stretch="Fill" Source="/Images/my_combo_icon.png" RenderTransformOrigin="0.5,0.5" Height="160" Width="80">
                        <Image.RenderTransform>
                            <CompositeTransform/>
                        </Image.RenderTransform>
                    </Image>
                </ScrollViewer>
            </Grid>

cs

    Storyboard1.Begin();

in the Loaded

But,i find that the animation don't work even it works well in the expression blend
So,can u help me find out what reason it is???
Or give me another way to implement this
thank U!!!
Any Advice will be great

4

1 回答 1

1

将您的ScrollViewer内容放在Grid这样的位置:

<ScrollViewer>
        <Grid>
            <Image x:Name="my_combo_pic" Stretch="Fill" Source="/Images/my_combo_icon.png" RenderTransformOrigin="0.5,0.5" Height="160" Width="266">
                <Image.RenderTransform>
                    <CompositeTransform />
                </Image.RenderTransform>
            </Image>
        </Grid>
</ScrollViewer>

这里的问题是动画系统有点混乱,因为它里面ScrollViewer只有Image一个本身不是容器的,所以它认为没有动画的地方(因为它与任何东西都不相关)。

于 2013-06-24T04:59:33.660 回答