1

I have popup "Now playing" window in my app, and now I want to apply any cool effect to its show/hide. I don't want to create/dispose window each time I need to show/hide it, so I suppose I can't use Window.Triggers. I created sample storyboard and invoke it from code-behind; So it instantly fall into exception No target was specified for 'System.Windows.Media.Animation.DoubleAnimation. I found this answer and added Storyboard.TargetName attribute.

    <Window.Resources>
        <Storyboard x:Key="OpenAnimation">
            <DoubleAnimation Storyboard.TargetName="NowPlaying" Storyboard.TargetProperty="(Window.Opacity)" Duration="0:0:5" From="0" To="1" />
        </Storyboard>
    </Window.Resources>

But it throws another exception: Can't find name "NowPlaying" in namespace "VKPlaylist.GUI.NowPlaying". But window code-behind class name IS NowPlaying. I also tried full name with namespace and it didn't change things.

How should I point proper name in this attribute? Is there any "magic" keyword like "this" so storyboard will know where to apply animation? I can't assign name attribute to window in XAML (and probably must not). It looks like dude in answer above easily solved his issue just by adding this attribute. What I am missing?

4

1 に答える 1

2

You need to set the Name attribute on your <Window> so that TargetName can reference it.

于 2013-06-02T17:41:31.100 に答える