I update xaml code for myControl.xaml:
<Grid x:Name="mygrid">
<Image Name="myImage" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Stretch="Uniform" Source="/1.jpg">
</Image>
</Grid>
The code for myControl.xaml.cs:
public MyControl()
{
InitializeComponent();
makeanim();
}
private void makeanim()
{
Storyboard sb = new Storyboard();
ThicknessAnimation SlideAnimation = new ThicknessAnimation();
SlideAnimation.Duration = TimeSpan.FromMilliseconds(1000);
SlideAnimation.From = new Thickness(500, 0, -500, 0);
SlideAnimation.To = new Thickness(0, 0, 0, 0);
SlideAnimation.BeginTime = TimeSpan.Zero;
SlideAnimation.DecelerationRatio = 0.9f;
Storyboard.SetTarget(SlideAnimation, myImage);
Storyboard.SetTargetProperty(SlideAnimation, new PropertyPath("(Image.Margin)"));
sb.Children.Add(SlideAnimation);
sb.Begin();
}
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.