Jeremy
Jeremy

Reputation: 46320

silverlight, how to implement a property of type StoryBoard

I have a user control and I want to create a property of type storyboard which I can set in xaml, so I tried to following, but I get a bad property error when I run it:

private Storyboard sbTransitionIn_m;
public Storyboard TransitionIn
{
    get {return sbTransitionIn_m;}
    set {sbTransitionIn_m = value;}
}

xaml:

<MyStuff:MyUserControl x:Name="ctlTest" TransitionIn="sbShow"/>

Upvotes: 1

Views: 315

Answers (2)

rravuri
rravuri

Reputation: 421

Define the storyboard in Resources and then refer it as staticresource

<UserControl.Resources>
   <Storyboard x:Key="sbShow">
     <!--  -->
   </Storyboard>
</UserControl.Resources>

<MyStuff:MyUserControl x:Name="ctlTest" TransitionIn="{StaticResource sbShow}"/>

Upvotes: 2

Michael S. Scherotter
Michael S. Scherotter

Reputation: 10785

Storyboard can't serialize from a string attribute like that. Try this:

<MyStuff:MyUserControl x:Name="ctlTest">
    <MyStuff:MyUserControl.TransitionIn>
        <Storyboard/>
    </MyStuff:MyUserControl.TransitionIn>
</MyStuff:MyUserControl>

Upvotes: 1

Related Questions