Well I dont completely understand your question, I fyou want to restart the animation you could do this:
private void StartAnimation(object sender, EventArgs e)
{
Double PosX = pl.ActualWidth;
if (PosX < MyCanvas.ActualWidth)
{
pl.Points.Add(new Point(time*20, Math.Sin(time)*20));
time += dt;
}
else
{
pl.Points.Clear();
time = 0;
pl.Points.Add(new Point(time * 20, Math.Sin(time) * 20));
time += dt;
}
}
You should consider using DispatcherTimer or the Storyboard if you want to do this. But you should provide additional information if I should help you :)