Reputation: 501
Im trying to get an image to be animated the moment the page is loaded but my approach doesnt seem to work on startup. But i have tested it with a button and it plays the animation no bother.
This is my constructor for my MainPage
public MainPage()
{
InitializeComponent();
CreatePanel();
var storyboard = new Animation();
var enterTop = new Animation
(
callback: d => bannerIcon.TranslationY = d,
start: -100,
end: 0,
easing: Easing.BounceOut
);
storyboard.Add(0, 1, enterTop);
storyboard.Commit(bannerIcon, "Banner", length: 1000);
Content = layout;
}
Should I have this code in the OnAppearing method or am I just coming at this completely wrong?
SOLUTION
Just had to move the animation code into the OnAppearing() method.
protected override void OnAppearing()
{
base.OnAppearing();
banner.IsVisible = false;
// animations
menuAnimations.FlyIn(banner, 1000);
menuAnimations.Rotate(btnSocial, 360);
menuAnimations.Rotate(btnVideo, 360);
menuAnimations.Rotate(btnSchedule, 360);
menuAnimations.Rotate(btnLunchMenu, 360);
menuAnimations.Rotate(btnContact, 360);
menuAnimations.Rotate(btnDetails, 360);
}
Upvotes: 1
Views: 861
Reputation: 373
Your running the animation before you Content is even set (Possible Animation is finished before you can even view it which help with argument of the animation working on button click I would also do as you suggested and move the animation.commit inside the OnAppearing method and set the animation to a longer length for testing purposes
Upvotes: 1