locked
How to use StoryBoard as an property of <BeginStoryBoard> RRS feed

  • Question

  • Hello:

    I have a storyboard defined in VisualState as follows for a StackPanel

    <VisualStateManager.VisualStateGroups>
        		<VisualStateGroup x:Name="VisualStateGroup">
        			<VisualStateGroup.Transitions>
        				<VisualTransition GeneratedDuration="0:0:12">
        					<Storyboard x:Name="myStoryBoard">
        						<DoubleAnimationUsingKeyFrames 

    Please note that StoryBoard is defined with "name" and not as Key.

    Now I want to start this StoryBoard upon "loaded" event of the stackpanel using EventTrigger as follows

    <StackPanel.Triggers>
                                <EventTrigger RoutedEvent="StackPanel.Loaded">
                                    <BeginStoryboard Storyboard="myStoryBoard"/>
                                </EventTrigger>
                            </StackPanel.Triggers>

    Whatever I tried to assign as Value of the StoryBoard Property, gives only an error. Can I specify StoryBoard within BeginStoryboard when StoryBoard is not defined in Key/value pair?

    Thanks

    Wednesday, November 6, 2013 3:22 AM

All replies

  • It doesn't seem so.  You might want to define it as a resource instead.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Marked as answer by biprism Wednesday, November 6, 2013 11:55 PM
    • Unmarked as answer by biprism Wednesday, November 6, 2013 11:55 PM
    Wednesday, November 6, 2013 8:36 PM
    Moderator
  • If I have to have my storyboard as Resources, then I cannot have it under VisualState, can I? It does not take x:Key attribute.

    What is the purpose of VisualState if I can achieve what I wanted without VisualState but as Resources?

    Thanks

    Wednesday, November 6, 2013 11:58 PM
  • Can you give me an app to work on?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Friday, November 8, 2013 2:08 PM
    Moderator