Prasanna Aarthi
Prasanna Aarthi

Reputation: 3453

XAML storyboard animation moving images from outside viewport-windows phone 8

I need to create a splash screen, where image needs to slide from bottom of the screen up.Initially it should be placed outside the viewport and then brought in.I understand i need to use story board animation,give target property as image's name and use render translate.Since m new to XAML.. I have the bare skeleton, I dunno how to build things up from here.. please help.

  <Grid HorizontalAlignment="Left" Height="1047" VerticalAlignment="Top" Width="480" Margin="0,-24,0,-255" Background="White">
    <Grid.Resources>
        <Storyboard x:Name="myanimation">
            <DoubleAnimation></DoubleAnimation>
        </Storyboard>
    </Grid.Resources>
    <Image HorizontalAlignment="Left" Height="252" Margin="0,795,0,0" VerticalAlignment="Top" Width="480" Source="/Assets/splash-bottom.png"/>
</Grid>

Upvotes: 1

Views: 9667

Answers (1)

ZombieSheep
ZombieSheep

Reputation: 29953

The easiest way to do this is the add a CompositeTransform to your image, initially set off the screen, and then animate the TranslateY property.

<Grid ...>
    <Grid.Resources>
        <Storyboard x:Name="MainImageSlideIn">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="MainImage">
                <EasingDoubleKeyFrame KeyTime="0" Value="900"/>
                <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </Grid.Resources>
    <Image x:Name="MainImage"HorizontalAlignment="Left" VerticalAlignment="Top" Width="480" Source="/Assets/splash-bottom.png">
        <Image.RenderTransform>
            <CompositeTransform TranslateY="900" />
        </Image.RenderTransform>
    </Image>
</Grid>

You'll also need to trigger the storyboard to begin. I can't remember the XAML for triggering it as an event, but you can add MainImageSlideIn.Begin() in your page's Loaded event in C#

Upvotes: 8

Related Questions