开发者

Cannot resolve TargetName error

Please provide answers in visual basic. Just want to know the syntax for the Storyboard.SetTargetName.

Me._StoryMoveLeft = New Storyboard
DAnim = New DoubleAnimation
Me._StoryMoveLeft.Children.Add(DAnim)
Storyboard.SetTargetName(DAnim, "SmoothRectTranslate")
Storyboard.SetTargetProperty(DAnim, New PropertyPath(TranslateTransform.XProperty))

Me._StoryMoveLeft.Stop()
danim = CType(Me._StoryMoveLeft.Children(0), DoubleAnimation)
DAnim.Duration = New Duration(ts)
DAnim.To = newDestinationRect.Left
Me._StoryMoveLeft.Begin() '<-- ERROR OCCOURS Cannot resolve TargetName SmoothRectTranslate.
<Rectangle x:Name="RectSmoot" Fill="Lime" Width="20" Height="20" Stroke="{Bindi开发者_C百科ng Stroke}" StrokeThickness="{Binding StrokeThickness}" HorizontalAlignment="Left" VerticalAlignment="Top" >
    <Rectangle.RenderTransform>
        <TranslateTransform X="20" Y="20" x:Name="SmoothRectTranslate" />
    </Rectangle.RenderTransform>
</Rectangle>


To use Storyboard.TargetName in code you need to create a NameScope, see the documentation of SetTargetName for an example of how to do that.

(By the way, if you have only one animation i would not use a Storyboard at all, it only means trouble, just call BeginAnimation on the transform)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜