Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
640 views
in Technique[技术] by (71.8m points)

c# - WPF Animation Warning: 6 : Unable to perform action

I observe in my WPF application warning in VIsual Studio Output panel with following text:

WPF 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='65981734'; Storyboard.Type='System.Windows.Media.Animation.Storyboard'; TargetElement='System.Windows.Controls.ContentPresenter'; TargetElement.HashCode='49882372'; TargetElement.Type='System.Windows.Controls.ContentPresenter'

How can I 'reverse' HashCode to some xaml element? How to find where that animation is attached?

Thanks in advance

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can use the following code to find your StoryBoard:

private string GetStoryBoardNameByHashCode(int hashCode)
{
    foreach (DictionaryEntry resource in Resources)
    {
        if (resource.Value is Storyboard)
        {
            if (resource.GetHashCode() == hashCode)
                return ((Storyboard) resource.Value).Name;
        }
    }
    return String.Empty;
}

Execute the method like so:

    string storyBoardName = GetStoryBoardNameByHashCode(65981734);

This should be able to get the StoryBoard-Name with the HashCode (ór if you want to get the specified StoryBoard, you can return that as well). Mind you that the ResourceDictionary is on Window-scope (local) here. So, if the StoryBoards are all located in the ResourceDictionary of the Application (App.xaml) then change 'Resources' to:

Application.Current.Resources

There may be an alternative way to get all the Resources of a WPF-application instead of just the local or Application-scope, but haven't looked into this. Hopefully, this code allows you to find your problem.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...