如何通过后面的代码将旋转动画效果添加到图像(C#) [英] How to put Swivel Animation effect to Image through code behind(C#)

查看:156
本文介绍了如何通过后面的代码将旋转动画效果添加到图像(C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法将XAML代码隐藏到后端C#代码中.
以下代码是为图像提供简单的旋转动画效果.

Iam not able to covert folowing XAML code to backend C# code.
Following code is to give simple swivel animation effect to image.

<Custom:Planerator Name="planerator" VerticalAlignment="Bottom" HorizontalAlignment="Center">
                <Image Name="logo" Source="Images.png" Stretch="None">
                    <Image.Triggers>
                        <EventTrigger RoutedEvent="Image.Loaded">
                            <BeginStoryboard>
                                <Storyboard TargetProperty="ScaleX" RepeatBehavior="Forever">
                                    <DoubleAnimation Storyboard.TargetName="planerator" 

                                             Storyboard.TargetProperty="RotationY"

                                             From="0" To="360"

                                             BeginTime="0:0:0"

                                             Duration="0:0:5"  

                                             AutoReverse="False"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                    </Image.Triggers>
                </Image>
            </Custom:Planerator>


请协助/帮助我.

预先谢谢您.


Please assist/help me.

Thank you in advance.

推荐答案

背后的代码"并不是真正的后端代码".这只是常规代码,只能自动生成.您可以轻松地找到生成的代码并了解其工作方式.为此,您必须首先构建基于XAML的程序集.完成后,在项目的目录结构下,更确切地说,在"obj"子目录下,找到生成的C#文件.您之前没有注意到该代码真是太好了.有人说:看不够,你必须看". :-)

顺便说一下,在许多其他情况下,学习自动生成的代码对于学习WPF的工作方式可能很有用.

—SA
"Code behind" is not really a "back-end code". This is just the regular code, only auto-generated. You can easily find the generated code and learn how it works. To do so, you have to build you XAML-based assembly first. When it''s done, find the generated C# files under the directory structure of the project, more exactly, under the "obj" sub-directory. It''s wonderful that you did not notice that code before. Some say: "looking is not enough, you have to see". :-)

By the way, learning the auto-generated code can be useful for learning how WPF works, in many other cases.

—SA


这篇关于如何通过后面的代码将旋转动画效果添加到图像(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆