I have an Prism application that begins with a Splash screen, then needs to change to a Start view. Here is the code for the Initialize method of the module I hoped would accomplish this:
public void Initialize() {
RegisterViewsAndServices();
//_manager.RegisterViewWithRegion(RegionNames.Content, typeof(ToolboxSplashView));
var vmSplash = _unityContainer.Resolve<IToolboxSplashViewModel>();
IRegion region = _regionManager.Regions[RegionNames.Content];
region.Add(vmSplash.View);
var vmStart = _unityContainer.Resolve<IToolboxStartViewModel>();
region.Deactivate(vmSplash.View);
region.Add(vmStart.View);
}
Unfortunately, when I run this I only see the Start view. If I comment out the Start view (last paragraph of the code), I see the start screen and the animation. How do I detect that the animation has completed and then change from Splash view to Start view?
Thanks.
Just a thought, use an AggregateEvent to announce that the animation has completed and have your controlling class execute the second part of your code when it receives that aggregate event notification.
public void Initialize()
{
RegisterViewsAndServices();
IEventAggregator ea = _unityContainer.Resolve<IEventAggregator>();
ea.GetEvent<WhateverEvent>().Subscribe(NavigateNext);
var vmSplash = _unityContainer.Resolve<IToolboxSplashViewModel>();
IRegion region = _regionManager.Regions[RegionNames.Content];
region.Add(vmSplash.View);
}
public void NavigateNext(object someParam)
{
//Navigation Code
var vmSplash = _unityContainer.Resolve<IToolboxSplashViewModel>();
var vmStart = _unityContainer.Resolve<IToolboxStartViewModel>();
region.Deactivate(vmSplash.View);
region.Add(vmStart.View);
}
//Shared code section (that both modules have access to)
public class WhateverEvent : CompositePresentationEvent<object> { }
//In your splash screen you will use the following line of code to publish
ea.GetEvent<WhateverEvent>().Publish(null);