我有一个用户控件,我想创建一个类型为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"/>
答案 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>