如何在Silverlight代码中设置PropertyPath

时间:2013-06-12 15:50:35

标签: silverlight

在xaml中,我的UserControl.Resources中有<Storyboard x:Name="WellGraphicStoryboard"></Storyboard>。 [我宁愿在我的代码中也有这个,但我无法弄清楚如何添加资源。]

在代码中,我有

        var duration = new Duration( TimeSpan.FromSeconds( 0.2 ) );
        var animation1 = new DoubleAnimation { Duration = duration };
        var sb = WellGraphicStoryboard;
        sb.Duration = duration;
        sb.Children.Clear( );
        sb.Children.Add( animation1 );
        Storyboard.SetTarget( animation1, _wellGraphic );
        Storyboard.SetTargetProperty( animation1, new PropertyPath( "SymbolSize" ) );
        animation1.To = 14;
        sb.Begin( );

_wellGraphic继承自MyGraphic,它有一个名为SymbolSize的双重属性。

当我点击sb.Begin时,我收到错误,无法解析TargetProperty SymbolSize。

我也试过了 Storyboard.SetTarget( animation1, ( MyGraphic )_wellGraphic );

我的目标是将_wellGraphic符号从原始值(7)增加到14,所以我愿意采用其他方法来完成这项工作。

0 个答案:

没有答案
相关问题