【发布时间】:2011-11-23 03:47:04
【问题描述】:
我有一个情节提要并想设置附加属性 VisualStateUtility.InitialState。我尝试了各种组合,但该属性从未得到解决。
我收到以下错误:无法解析 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));
【问题讨论】:
-
你能提供你的附属财产的声明吗?您不会通过 TargetProperty 中的完全限定名称来引用它,因为点仅表示子成员,而不是命名空间。只是简短的版本“InitialState”。
-
...当您确实添加了 12 小时前所做的更改时,请确保添加后续评论,以便我们真正注意到 :)
-
+1 用于提供代码。更容易看出哪里出了问题:)
标签: c# silverlight storyboard visualstatemanager