Hi All,
Could you pleas help me, how can i continuously working Animation on Button click. In my app i animated my control in loaded event. On the same window i have button and when i click that button it search the data from database(these event take some time to search date from database). In between time my control animation stopped. Could you please tell, how to make animation continuously, even i click the button.
I have demonstrate the simple code below. In this code rectangle opacity animated from 0 to 1 for this loaded event. when click button, the action sleep for 5 sec(using Thread.Sleep()). In between time rectangle animation stopped. After action exit from click event, it animated.
<Grid><StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center" ><Button Height="40" Width="100" Content="Click" Click="Button_Click_1" /><Rectangle Fill="Red" Height="50" Width="50" Margin="0,30,0,0" x:Name="rect" ><Rectangle.Triggers><EventTrigger RoutedEvent="Rectangle.Loaded"><EventTrigger.Actions><BeginStoryboard><Storyboard RepeatBehavior="Forever" Duration="0:0:1" ><DoubleAnimation Storyboard.TargetProperty="(Rectangle.Opacity)" Storyboard.TargetName="rect" From="0" To=" 1"></DoubleAnimation></Storyboard></BeginStoryboard></EventTrigger.Actions></EventTrigger></Rectangle.Triggers></Rectangle></StackPanel></Grid>
private void Button_Click_1(object sender, RoutedEventArgs e) { Thread.Sleep(5000); }
Regards,
M. Sheik