gpt4 book ai didi

c# - 将 silverlight 动态动画移动到 WPF

转载 作者:行者123 更新时间:2023-11-30 17:15:21 25 4
gpt4 key购买 nike

我有 silverlight 动画(可以 100% 确定):

<UserControl.RenderTransform>
<CompositeTransform/>
</UserControl.RenderTransform>

在代码中:

Storyboard.SetTargetProperty(myDoubleAnimation1, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.TranslateX)"));
Storyboard.SetTargetProperty(myDoubleAnimation2, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.TranslateY)"));

我在 WPF 中试过这个:

<UserControl.RenderTransform>
<TranslateTransform />
</UserControl.RenderTransform>

和:

Storyboard.SetTargetProperty(myDoubleAnimation1, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.X)"));
Storyboard.SetTargetProperty(myDoubleAnimation2, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.Y)"));

但它会崩溃,但路径 (UIElement.RenderTransform).(TranslateTransform.X) 无法解析或类似这样的异常。你能帮忙吗?

最佳答案

解决方法:

代码隐藏:

Storyboard.SetTargetProperty(myDoubleAnimation1, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.X)"));
Storyboard.SetTargetProperty(myDoubleAnimation2, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.Y)"));

标记:

<UserControl.RenderTransform>
<TransformGroup>
<TranslateTransform />
</TransformGroup>
</UserControl.RenderTransform>

关于c# - 将 silverlight 动态动画移动到 WPF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8105284/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com