Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Timer Stop the others animations
1 replies. Latest Post by johndd on December 24, 2008.
(0)
Dialogic...
Member
32 points
36 Posts
12-22-2008 11:56 AM |
Hi,
I have a timer for execute a dinamyc storyboard in my page.xaml, but when this storyboard is executing, I can't do anothers actions in my page (for example if I am writing in a textbox when the timer_tick, the writer stop).
In my xaml I have:
<vsm:VisualStateGroup x:Name="EstadoImagenes"> <vsm:VisualStateGroup.Transitions> <vsm:VisualTransition GeneratedDuration="00:00:02"/> </vsm:VisualStateGroup.Transitions> <vsm:VisualState x:Name="Estado1"/> <vsm:VisualState x:Name="Estado2"> <Storyboard> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="foto" Storyboard.TargetProperty="(UIElement.Opacity)"> <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="foto2" Storyboard.TargetProperty="(UIElement.Opacity)"> <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </vsm:VisualState> </vsm:VisualStateGroup> .... <TextBox Height="Auto" Cursor="Hand" HorizontalAlignment="Right" Margin="0,0,20,0" x:Name="terminos" VerticalAlignment="Center" Width="Auto" FontFamily="Verdana" FontSize="10" TextAlignment="Right" />
And In the codebehind
Dim timer1 As System.Windows.Threading.DispatcherTimer Dim timerControl As System.Windows.Threading.DispatcherTimer Public Sub New() InitializeComponent() 'Creamos el temporizador que camiará las imágenes timer1 = New System.Windows.Threading.DispatcherTimer() timer1.Interval = TimeSpan.FromSeconds(5) timerControl = New System.Windows.Threading.DispatcherTimer() timerControl.Interval = TimeSpan.FromSeconds(2) timerControl.Stop() AddHandler timer1.Tick, AddressOf Timer_Tick AddHandler timerControl.Tick, AddressOf EfectoImagen_Completed timer1.Start() End sub Private Sub Timer_Tick() timer1.Stop() CambiarImagen() End Sub Private Sub CambiarImagen() If currentFoto = 1 Then VisualStateManager.GoToState(Me, "Estado2", True) Else VisualStateManager.GoToState(Me, "Estado1", True) End If timerControl.Start() End Sub Private Sub EfectoImagen_Completed() timerControl.Stop() ActualizarImagen() timer1.Start() End Sub Private Sub ActualizarImagen() If i >= images.Count - 1 Then i = 0 Else If currentFoto = 1 Then foto.Source = New BitmapImage(New Uri("../" & _SkinDir & "Carrusel/" & System.IO.Path.GetFileName(images(i)), UriKind.RelativeOrAbsolute)) currentFoto = 2 Else foto2.Source = New BitmapImage(New Uri("../" & _SkinDir & "Carrusel/" & System.IO.Path.GetFileName(images(i)), UriKind.RelativeOrAbsolute)) currentFoto = 1 End If i += 1 End If End Sub
I'm using two timers because, I haven't get use Completed Event for "EstadoImagenes".
Can I solved this?
Excuse for me English.
Best Regards.
johndd
260 points
76 Posts
12-24-2008 6:23 AM |
I'm struggling with the description a little so I may be answering the wrong question.
If you want to disable controls while the animation is running you could try to do this within the animation by using an ObjectKeyFrame to set the Enabled property of the controls to False at the start of the storyboard and back to True at the end of the storyboard.