我有一个用户控件,我想创建一个可以在xaml中设置的storyboard类型的属性,所以我尝试了以下操作,但在运行它时得到了一个糟糕的属性错误:
private Storyboard sbTransitionIn_m;
public Storyboard TransitionIn
{
get {return sbTransitionIn_m;}
set {sbTransitionIn_m = value;}
}
xaml:
<MyStuff:MyUserControl x:Name="ctlTest" TransitionIn="sbShow"/>
发布于 2009-01-06 05:31:28
在参考资料中定义故事板,然后将其称为staticresource
<UserControl.Resources>
<Storyboard x:Key="sbShow">
<!-- -->
</Storyboard>
</UserControl.Resources>
<MyStuff:MyUserControl x:Name="ctlTest" TransitionIn="{StaticResource sbShow}"/>
发布于 2009-01-06 00:33:44
故事板不能从那样的字符串属性序列化。试试这个:
<MyStuff:MyUserControl x:Name="ctlTest">
<MyStuff:MyUserControl.TransitionIn>
<Storyboard/>
</MyStuff:MyUserControl.TransitionIn>
</MyStuff:MyUserControl>
https://stackoverflow.com/questions/414959
复制相似问题