WPF Animation Warning: 6 : Unable to perform action

前端 未结 3 750
北海茫月
北海茫月 2020-12-01 22:44

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

WPF Animation Warning: 6 : Unable to perform action because

相关标签:
3条回答
  • 2020-12-01 23:09

    Actually, I had run into the same problem as you.

    I had found that the animation's Begin() method didn't get called before its Stop() method being called. So the Runtime throw a warning that the Stop action couldn't be invoked.

    0 讨论(0)
  • 2020-12-01 23:09

    My issue was I had a trailing space in my EventName.

    <interactivity:EventTrigger EventName="SelectionChanged ">
    

    changed to

    <interactivity:EventTrigger EventName="SelectionChanged">
    
    0 讨论(0)
  • 2020-12-01 23:30

    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.


    Here's the sample code, just in case you'd need it!

    0 讨论(0)
提交回复
热议问题