silverlight,如何实现StoryBoard类型的属性

时间:2009-01-05 23:48:15

标签: .net silverlight

我有一个用户控件,我想创建一个类型为storyboard的属性,我可以在xaml中设置,所以我试着关注,但是当我运行它时出现了一个错误的属性错误:

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

XAML:

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

2 个答案:

答案 0 :(得分:2)

在参考资料中定义故事板,然后将其作为staticresource

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

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

答案 1 :(得分:1)

Storyboard无法从类似的字符串属性序列化。试试这个:

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