this is the last thing I Achieved : I added the animation to the buttons programmatically this is the code behind file :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
namespace practiceOnAnimationClasses
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
DoubleAnimationUsingPath Animation1 = new DoubleAnimationUsingPath();
private void Window\_Loaded(object sender, RoutedEventArgs e)
{
List<Button> buttons = new List<Button>(5);
buttons.Add(new Button() { Width = 120d, Height = 75d, Content = "Advertisement 1" });
buttons.Add(new Button() { Width = 120d, Height = 75d, Content = "Advertisement 2" });
buttons.Add(new Button() { Width = 120d, Height = 75d, Content = "Advertisement 3" });
buttons.Add(new Button() { Width = 120d, Height = 75d, Content = "Advertisement 4" });
buttons.Add(new Button() { Width = 120d, Height = 75d, Content = "Advertisement 5" });
// Storyboard AnimationRectanglePath = (Storyboard)this.Resources\["StoryboardPath"\];
int count = 0;
foreach (var item in buttons)
{
MainCanvas.Children.Add(item);
DoubleAnimation myDoubleAnimation = new DoubleAnimation();
myDoubleAnimation.From = 75 + (count \* item.Width);
myDoubleAnimation.To = 800;
myDoubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(15));
myDoubleAnimation.AutoReverse = false;
myDoubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
// Apply the animation to the button's Width property.
item.BeginAnimation(Canvas.LeftProperty, myDoubleAnimation);
count++;
}
}
}
}
Xaml File it only contains the mainCanvas that I will Add Buttons to It the movement is very creasy and wrong How Can I make the movement