首页 新闻 搜索 专区 学院

win8自定义的依赖属性,但是使用故事版动画时出错,有谁遇到过?

0
悬赏园豆:10 [待解决问题]

自定义依赖属性

public class MyCanvas : Canvas
    {
        /// <summary>
        /// 获取或设置身体图片
        /// </summary>
        public double TestWidth
        {
            get { return (double)GetValue(TestWidthProperty); }
            set { SetValue(TestWidthProperty, value); }
        }
        public static readonly DependencyProperty TestWidthProperty = DependencyProperty.Register(
            "TestWidth",
            typeof(double),
            typeof(MyCanvas),
            new PropertyMetadata(0, new PropertyChangedCallback(ChangeTestWidthProperty))
        );
        public static void ChangeTestWidthProperty(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MyCanvas objectBase = d as MyCanvas;
            objectBase.Width = (double)e.NewValue;
        }
    }

动画调用

DoubleAnimation animation = new DoubleAnimation() { From = 100, To = 300 };
            animation.EnableDependentAnimation = true;
            Storyboard.SetTarget(animation, img);
            Storyboard.SetTargetProperty(animation, "TestWidth");
            var storyboard = new Storyboard();
            storyboard.Children.Add(animation);
            storyboard.Begin();

但是报错,望有知道的人解答,难道自定属性win8 app不支持动画?

小芒果的主页 小芒果 | 初学一级 | 园豆:194
提问于:2012-09-17 22:58
< >
分享
所有回答(2)
0

还真没看出错在那1

jason2013 | 园豆:1998 (小虾三级) | 2012-09-18 16:21
0

targetname 呢

GIS-MAN | 园豆:200 (初学一级) | 2012-09-18 17:38
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册