我有一个故事板,想设置附加属性 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));