我是WPF Storyboard的新手,我定义了以下两个故事板。
<Storyboard x:Key="sbShowLeftMenu" Completed="Storyboard_Completed" >
<ThicknessAnimation Storyboard.TargetProperty="Margin" From="-100,0,0,0" To="0,0,0,0" DecelerationRatio=".9" Duration="0:0:1" />
</Storyboard>
<Storyboard x:Key="sbHideLeftMenu" Completed="Storyboard_Completed">
<ThicknessAnimation Storyboard.TargetProperty="Margin" From="0,0,0,0" To="-100,0,0,0" AccelerationRatio=".9" Duration="0:0:1" />
</Storyboard>
我发现两种情况同时被触发的情况。如何确保只在另一个完成后触发一个?我知道有完成的事件,但不知道如何使用它。
答案 0 :(得分:0)
<Storyboard x:Key="sbShowLeftMenu" Completed="Storyboard_Completed" >
<ThicknessAnimation Storyboard.TargetProperty="Margin" From="-100,0,0,0" To="0,0,0,0" DecelerationRatio=".9" Duration="0:0:1" />
</Storyboard>
<Storyboard x:Key="sbHideLeftMenu">
<ThicknessAnimation Storyboard.TargetProperty="Margin" From="0,0,0,0" To="-100,0,0,0" AccelerationRatio=".9" Duration="0:0:1" />
</Storyboard>
请注意,我已删除了第二个Storyboard_Completed
(除非您需要它)。
private void Storyboard_Completed(...)
{
sbHideLeftMenu.Begin();
}