我收到以下错误:无法解析TargetProperty(VisualStateUtility.InitialState)
如何在Storyboard上设置自定义附加属性的值?
<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="(Fully.QualifIEd.namespace.VisualStateUtility.InitialState)" Storyboard.Targetname="Expanderbutton">
public static string GetinitialState(DependencyObject obj) { return (string)obj.GetValue(InitialStateProperty); } public static voID SetinitialState(DependencyObject obj,string value) { obj.SetValue(InitialStateProperty,value); } // Using a DependencyProperty as the backing store for InitialState. This enables animation,styling,binding,etc... public static Readonly DependencyProperty InitialStateProperty = DependencyProperty.Registerattached("InitialState",typeof(string),typeof(VisualStateUtility),new PropertyMetadata(null,OnInitialStatePropertyChanged));解决方法 这应该可以解决问题
<ObjectAnimationUsingKeyFrames x:name="animation" Duration="0" Storyboard.TargetProperty="xmlnsAlias:VisualStateUtility.InitialState" Storyboard.Targetname="Expanderbutton">
注意如何将名称添加到动画中,从目标属性名称中删除括号,然后使用xaml标头中的xmlns别名作为前缀.
在你的代码背后,你必须添加这个:
InitializeComponent();Storyboard.SetTargetProperty(animation,new PropertyPath(Fully.QualifIEd.namespace.VisualStateUtility.InitialState));
显然,最后一步是动画自定义附加属性所必需的.如果你问我,真的很痛苦.
总结以上是内存溢出为你收集整理的c# – 在StoryBoard上设置自定义附加属性全部内容,希望文章能够帮你解决c# – 在StoryBoard上设置自定义附加属性所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)