private async void moveMessage()
{
movingLabel = new Label();
movingLabel.HorizontalTextAlignment = TextAlignment.Center;
stackLayoutContainingMovingText.Children.Add(movingLabel);
Animation animation = new Animation();
double height = Application.Current.MainPage.Height;
movingLabel.Text = "MESSAGE";
animation.Commit(movingLabel, "animation", 20, 0, Easing.Linear, (d, f) =>
{
movingLabel.TranslateTo(0, height, 0, Easing.Linear);
movingLabel.TranslateTo(0, -height, 2000, Easing.Linear);
});
await Task.Delay(2000);
stackLayoutContainingMovingText.Children.Remove(movingLabel);
}
I am calling this method every time a button is clicked. This will animate a label of text to move from the bottom to the top of the screen.
For some reason, I have to create a new label and add it to the stacklayout children because if I don't this animation will only happen once and won't repeat.
Currently this code kind of works, but it pushes all of the controls on the page up and then down during animation. I also want to be able to have the button pressed multiple times which should allow multiple labels to be animating upward at the same time.