Click here to Skip to main content
15,064,166 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I have a problem with controlling the instance of the class Storyboard.

It's defined in XAML in Resources:

C#
<Window.Resources>
    <Storyboard x:Name="Storyboard1" x:Key="Storyboard1">


Also I'm trying to make it stop, like this:

C#
Storyboard sb = (Storyboard)this.TryFindResource("Storyboard1");
sb.Seek(TimeSpan.Zero);


But, no success. If I try to call in your code to the instance Storybord1 then I've got the errors, that there is NO such instance in the current context (and also, if in C# code I try to look with intellisense also no succes, cause of describing pervious problem).

When I'm trying to find this instance with:

C#
foreach (var item in this.Resources)
{
    MessageBox.Show(item.ToString());
}


No success.

I'm not doing smth difficult or using super-encapsulated design pattern, that I can't find/use it.

Just add one UI element and one Storyboard with changing opacity.

I want just to control by myself all Storyboard's play. When I can Stop it and Start it.

In Silverlight I don't get any troubles ( cause Storyboard1 is accessible in Silverlight ), but in WPF all storyboards by defualt are auto-playing and I can't control the its instances.

How can I solve it?

Thank you!
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900