How to check the storyboard whether this is begin or not?

▼魔方 西西 提交于 2020-01-24 17:00:06

问题


I need to know whether the Storyboard is begun or not. If it is begun, I need to stop, otherwise I no need to stop. Both begin and stop will be done in code behind.

Currently I've done this:

if (parameter != null && parameter is System.Windows.Media.Animation.Storyboard)
{
    if (!(bool)value)
    {
        (parameter as System.Windows.Media.Animation.Storyboard).Begin();
        return Visibility.Visible;
    }
    else
    {
        (parameter as System.Windows.Media.Animation.Storyboard).Stop();
        return Visibility.Collapsed;
    }
}

I have faced the binding error:

System.Windows.Media.Animation Warning: 6 : Unable to perform action because the specified Storyboard was never applied to this object for interactive control.; Action='Stop'; Storyboard='System.Windows.Media.Animation.Storyboard'; Storyboard.HashCode='7861304'; Storyboard.Type='System.Windows.Media.Animation.Storyboard'; TargetElement='System.Windows.Media.Animation.Storyboard'; TargetElement.HashCode='7861304'; TargetElement.Type='System.Windows.Media.Animation.Storyboard'

Can anyone share how to stop the storyboard once its begun?

来源:https://stackoverflow.com/questions/32731701/how-to-check-the-storyboard-whether-this-is-begin-or-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!