Click here to Skip to main content
15,886,007 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Iam not able to covert folowing XAML code to backend C# code.
Following code is to give simple swivel animation effect to image.
HTML
<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.
Posted
Updated 25-May-14 6:32am
v3
Comments
[no name] 24-May-14 16:01pm    
Help you with what? Have you tried to do this yourself? What was the problem that you encountered? Why convert it at all? Did you know that you can use XAML as a resource from your code behind? We are not a code translation service. You could at least attempt this yourself and tell us the problem that you ran into with what you have tried.
bishwajeet sarkar 24-May-14 16:22pm    
I am new for the concept Advance Animation part of WPF, and I am trying to use swivel Animation effect through Code Behind(C#) for an image.
I tried but it gave me exception:

"Object 'System.Double' cannot be used as an accessor parameter for a PropertyPath. An accessor parameter must be DependencyProperty, PropertyInfo, or PropertyDescriptor."



DoubleAnimation da = new DoubleAnimation(0, 360, new Duration(TimeSpan.FromSeconds(2)));
Storyboard sb = new Storyboard();
sb.RepeatBehavior = RepeatBehavior.Forever;
sb.Children.Add(da);
sb.Duration=new Duration(TimeSpan.FromSeconds(2));
Storyboard.SetTarget(da, logo);
Storyboard.SetTargetProperty(da, new PropertyPath(planerator.RotationY));
Storyboard.SetTargetProperty(da, new PropertyPath(ScaleTransform.ScaleXProperty));
sb.Begin();


I want to know that, How to use RotationY Property for animation with the help of Double animation.

1 solution

"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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900