在 StoryBoard 上设置自定义附加属性

Bri*_*ian 5 c# silverlight visualstatemanager storyboard

我有一个故事板,想要设置附加属性 VisualStateUtility.InitialState。我尝试过各种组合,但属性从未得到解决。

我收到以下错误:无法解析 TargetProperty (VisualStateUtility.InitialState)

如何在 Storyboard 上设置自定义附加属性的值?

<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="(Fully.Qualified.Namespace.VisualStateUtility.InitialState)"  Storyboard.TargetName="ExpanderButton">
Run Code Online (Sandbox Code Playgroud)

    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));
Run Code Online (Sandbox Code Playgroud)

Bri*_*ian 0

我遇到了这个:

http://forums.silverlight.net/t/182227.aspx

另一位用户说它不受支持。

弗兰克·兰写道:

您好,这是一个已知问题。解决方法似乎是:通过代码而不是 xaml 对自定义附加属性进行动画处理。对于该问题造成的任何不便,我们深表歉意。Frank Lan Microsoft 在线社区支持