我正在为应用栏图标按钮(类似于PhoneFlipMenu工具)实现我自己的弹出菜单。我正在为弹出窗口使用垂直 StackPanel,当单击相应的应用栏按钮时,我需要用动画显示它。代码如下所示:
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();
}
主要问题是动画在应用程序栏隐藏之前开始。结果,弹出菜单在那之后跳跃了一点。应用栏完全隐藏后如何运行动画?