I'm in the process of implementing my own popup menu for app bar icon buttons (something similar to the PhoneFlipMenu tool). I'm using a vertical StackPanel for my popup, and I need to display it with animation when the corresponding app bar button is clicked. The code looks like this:
private void appBarIconButtonList_Click(object sender, EventArgs e)
{
ApplicationBar.IsVisible = false;
AnimatePopupMenuListCommands(true);
}
private void AnimatePopupMenuListCommands(bool openMenu)
{
PlaneProjection planeProjection = popupMenuListCommands.Projection as PlaneProjection;
DoubleAnimation anima = new DoubleAnimation();
if (openMenu)
{
anima.From = 90;
anima.To = 0;
}
else
{
anima.From = 0;
anima.To = 90;
}
anima.Duration = new Duration(TimeSpan.FromSeconds(0.1));
Storyboard.SetTarget(anima, planeProjection);
Storyboard.SetTargetProperty(anima, new PropertyPath(PlaneProjection.RotationXProperty));
Storyboard storyboard = new Storyboard();
storyboard.Children.Add(anima);
storyboard.Begin();
}
The main problem is that the animation begins before the application bar is hidden. As a result, the popup menu jumps a little bit after that. How to run the animation after the application bar has been totally hidden?