Animations are cutoff

Topics: Prism v2 - WPF 3.5
Oct 13, 2009 at 6:00 PM

Hi,

I've got some fade-in/fade-out animations that are triggered when a view is removed and added to a region. The initial fade-in works fine, but a fade-in after a fade-out is clipped.  The animation timeline is set to 500 ms.  This problem doesn't happen when I boost the timeline to a value closer to 1000ms.  By 'clipped', I mean that the last part of the fade-in animation might appear (say 20ms out of 500 ms) or it just doesn't appear to be an animated fade-in.  

First, a 'leave' animation is triggered and the following 

 

this.VisibilityService.LeaveViewAnimation(screen.View, () =>
                                                                               {
                                                                                   mainRegion.Deactivate(screen.View);
                                                                                   mainRegion.Remove(screen.View);
                                                                                   IScreen newScreen = EnsureScreenExists(args.ScreenKey, args.ScreenSubject, args.RegionName);
                                                                                   ShowScreen(args.ScreenKey, args.RegionName);
                                                                               });

this.VisibilityService.LeaveViewAnimation(screen.View, () =>

                                                                               {

                                                                                   mainRegion.Deactivate(screen.View);

                                                                                   mainRegion.Remove(screen.View);

                                                                                   IScreen newScreen = EnsureScreenExists(args.ScreenKey, args.ScreenSubject, args.RegionName);

                                                                                   ShowScreen(args.ScreenKey, args.RegionName);

                                                                               });

public void LeaveViewAnimation(UserControl view, Action onLeaveComplete)

        {

            this.LeaveViewVisibilityStoryboard = new Storyboard();

            this.LeaveViewVisibilityStoryboard.Completed += new EventHandler((sender, e) => onLeaveComplete());

            PerformAnimation(view, this.LeaveViewVisibilityStoryboard, 500);

            this.LeaveViewVisibilityStoryboard.Completed -= new EventHandler((sender, e) => onLeaveComplete());

        }

Second, the new view is inserted and activated

targetRegion.Add(screen.View);

targetRegion.Activate(screen.View);

 

Third, a entry animation begins

this.EnterViewVisibilityStoryboard.Begin();

 

I've left out some intermediary code for the setup of the animations.  

Is the problem related to the timing of view loading events???