开发者

How to move a StackPanel in WPF

开发者 https://www.devze.com 2023-03-23 11:01 出处:网络
I would like to move a StackPanel horizontally when the user clicks a button.I\'m开发者_Go百科 implementing DoubleAnimation with TargetName and TargetProperty.But, I don\'t know which TargetProperty t

I would like to move a StackPanel horizontally when the user clicks a button. I'm开发者_Go百科 implementing DoubleAnimation with TargetName and TargetProperty. But, I don't know which TargetProperty to use.

Can anyone help me?


If you put the StackPanel inside a Canvas you can achieve this behavior by setting the Canvas.X and Canvas.Y properties. Alternatively you could animate the Margin of the StackPanel by using ThicknessAnimation. Check out this post for a similar request.


Another method would be a TranslateTransform applied to the RenderTransform of the StackPanel. The TargetProperty path for the animation then would be RenderTransform.X.

0

精彩评论

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

关注公众号