Click here to Skip to main content
15,923,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<Window x:Class="rotat.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">

    <Window.Resources>
        <Storyboard x:Key="sbdRotation"  RepeatBehavior="Forever">
            <DoubleAnimation
            Storyboard.TargetName="image"
            Storyboard.TargetProperty="(Image.LayoutTransform).(RotateTransform.Angle)"
            From="0" To="360"   Duration="0:0:0:1" FillBehavior="Stop"/>
        </Storyboard>

    </Window.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>

        <Image Name="image" Width="50" Height="50" Source="C:\Users\shreddy.FAREAST\Pictures\disk1.png">
            <Image.LayoutTransform>
                <RotateTransform CenterX="0.5" CenterY="0.5" />
            </Image.LayoutTransform>
        </Image>

        <Button Grid.Row="1" Content="Rotate the image!" Click="Button_Click" Width="100" Height="100" Margin="106,30,311,29" />
        <Button x:Name="stop" Width="100" Height="100" Margin="308,20,109,39" Grid.Row="1" Click="stop_Click" Content="stop"/>
    </Grid>
</Window>



and my c# code

C#
public MainWindow()
     {
         InitializeComponent();
         sd = new Storyboard();
         sd = (Storyboard)FindResource("sbdRotation");
     }
     public void Button_Click(object sender, RoutedEventArgs args)
     {

         //while (mn>0)
         //{

             sd.Begin(this);
             mn--;
             d++;
        // }
     }

     private void stop_Click(object sender, RoutedEventArgs e)
     {
         sd.Stop(this);
     }


But not able to stop the rotation
Posted
Updated 23-Aug-13 3:02am
v2

1 solution

Hello Shalini,

Please use this code while you Begin your storyboard,

sd.Begin(this,true);


Here second argument is controllable. Due to this you can control to your animation..

For more information -

http://msdn.microsoft.com/en-us/library/system.windows.media.animation.storyboard.aspx[^]


Hope this will help you..
 
Share this answer
 
v2

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