0

How can i make image move on Y axis from top to bottom like in slots ? I have i my WPF this:

<Border BorderBrush="Black" Margin="62,97,398,128.6" BorderThickness="2" Name="border" >
                    <Grid>
                        <Image Name="obrazekAutomat1" Source="cisla/2.png"/>
                    </Grid>
</Border>

I would prefer it in CodeBehind. But i think if you give me XAML i would be able to rewrite it in C#.

Thanks :)

2 Answers2

0

Like every other control, Image Control has a RenderTransform property that you can either set using WPF or C# code, and eventually animate its "Y" property using a double animation.

These links will help you in adding a translate transform and animating it:

http://www.c-sharpcorner.com/uploadfile/mahesh/translatetransform-in-wpf/

http://www.codeproject.com/Articles/23257/Beginner-s-WPF-Animation-Tutorial

uncommon_name
  • 470
  • 2
  • 5
  • 19
0

This should work as code behind, where this is your control

this.RenderTransform = new TranslateTransform();

((TranslateTransform) this.RenderTransform).BeginAnimation(TranslateTransform.YProperty,
    new DoubleAnimation(-100, 100, TimeSpan.FromMilliseconds(1000)));
bto.rdz
  • 6,636
  • 4
  • 35
  • 52
  • Cool thats how i wanted it. But i have last question: How can i make a part of the picture disappear when it leaves border ? Screen: https://beta.ctrlv.cz/qITU – Lukas Seidler May 15 '16 at 06:57
  • @LukasSeidler Wrap the in a , then set the Cavnas.ClipToBound property to true, that will make the trick – bto.rdz May 15 '16 at 19:09