Hi,
Indeed, I have tried moving the HelloWorldView code to the Shell window, and the RegionManagerAwareBehavior was unable to set the RegionManager property in the ClientsView. It seems that again, this is a timing issue regarding the initialization of the components of Prism's region system.
Although so far I am unable to point the exact cause of the timing problem this time, the good news is that we have several workarounds we can apply to this. Some have been already discussed in this thread before:
However, take into account that this approach might not be recommended for all scenarios.
Regards,
Damian Cherubini
http://blogs.southworks.net/dcherubini
Indeed, I have tried moving the HelloWorldView code to the Shell window, and the RegionManagerAwareBehavior was unable to set the RegionManager property in the ClientsView. It seems that again, this is a timing issue regarding the initialization of the components of Prism's region system.
Although so far I am unable to point the exact cause of the timing problem this time, the good news is that we have several workarounds we can apply to this. Some have been already discussed in this thread before:
- Add the ClientsView after "initialization." (e.g. not by using view discovery)
-
Define the InteractionRequestTriggers in a view that will be injected in a region instead of defining them directly in the Shell.
// IRegionManagerAware implementationpublic IRegionManager RegionManager { get { returnthis.regionManager; } set { this.regionManager = value; // We remove and re-add the views to trigger the behaviors again.// This might break some views / view models that have logic that execute in response // to them being add / removed / activated / deactivated in a region. List<object> views = new List<object>(); foreach (var view inthis.regionManager.Regions["DetailsRegion"].Views) { views.Add(view); } foreach (var view in views) { this.regionManager.Regions["DetailsRegion"].Remove(view); } foreach (var view in views) { this.regionManager.Regions["DetailsRegion"].Add(view); } } }
Regards,
Damian Cherubini
http://blogs.southworks.net/dcherubini