Hi,
for parallel fadeout and fadein use only one StoryBoard with 2 animations like this:
Friend Module WindowFadeTransition
Friend Sub Transition(from As FrameworkElement, [to] As FrameworkElement)
ConfigureAnimation(from, [to])
TransitionStoryboard.Begin()
End Sub
Private Sub ConfigureAnimation(from As DependencyObject, [to] As DependencyObject)
TransitionStoryboard.Children.Clear()
Dim fadeOutAnimation As New DoubleAnimation
With fadeOutAnimation
.To = 0
.Duration = Duration
End With
TransitionStoryboard.Children.Add(fadeOutAnimation)
Storyboard.SetTarget(fadeOutAnimation, from)
Storyboard.SetTargetProperty(fadeOutAnimation, New PropertyPath(UIElement.OpacityProperty))
Dim fadeInAnimation As New DoubleAnimation
With fadeInAnimation
.To = 1
.Duration = Duration
End With
TransitionStoryboard.Children.Add(fadeInAnimation)
Storyboard.SetTarget(fadeInAnimation, [to])
Storyboard.SetTargetProperty(fadeInAnimation, New PropertyPath(UIElement.OpacityProperty))
End Sub
Private ReadOnly Property Duration As New Duration(TimeSpan.FromSeconds(10))
Private ReadOnly Property TransitionStoryboard As New Storyboard
End Module
End Namespace