Search code examples
animationwindows-8clipping

Animate a RectangleGeometry (inside an Image.Clip) in Windows 8/Metro/Store


I am trying to animate an image Clip that is made using a RectangleGeometry.

However, I can't find any solution to do that. I have already reached the following conclusions:


Solution

  • I ended up adding adding a Transform in the RectangleGeometry and I animated it:

    <!-- In the Clip Section -->
    <RectangleGeometry 
        x:Name="RectangleGeometry"  
        Rect="0,0,727,400" >
        <RectangleGeometry.Transform>
             <TranslateTransform x:Name="ClipTransform"/>
        </RectangleGeometry.Transform>
    </RectangleGeometry>
    
    <!-- Animate the Clip Section -->
    <Storyboard x:Name="Anim">
        <DoubleAnimation 
            Duration="0:0:1" 
            To="-100"
            Storyboard.TargetName="ClipTransform"          
            Storyboard.TargetProperty="Y"  />
    </Storyboard>
    

    I don't know if there is a better solution, but this one was the one I found.