Blendability when using Regions

Topics: Prism v4 - WPF 4
Jan 29, 2014 at 7:36 PM
A UserControl may have a d:DataContext="{d:DesignInstance... combinations which of course works great when designing the UserControl.
However, when another View is composed by RequestNavigate(string regionName, string source) (where source refer to the UserControl) the designtime DataContext on the UserControl is lost.
It works perfectly in runtime.
Someone knows how to make this working in designtime ?
Prism version is 4.1.
.NET framework version is 4.0.

Something better coming in Prism 4.2 ?

B.t.w. I am using MEF as container.
Developer
Feb 3, 2014 at 9:05 PM
Hi,

Something interesting here is that, as far as I know, Prism's regions were never designed to be used during design time. For that reason when creating a region the RegionManager checks if the application is running inside a designed and if so, the region is not created:
private static void OnSetRegionNameCallback(DependencyObject element, DependencyPropertyChangedEventArgs args)
{
    if (!IsInDesignMode(element))
    {
        CreateRegion(element);
     }
}
Therefore, it would be helpful if you could provide more information about how you are using regions in design time, since they should not have been created in the first place.

Thanks,

Damian Cherubini
http://blogs.southworks.net/dcherubini
Feb 3, 2014 at 10:20 PM
Thanks, looks like I expressed myself badly. What I meant was something like: another View is configured to be composed by RequestNavigate...
I did not mean that the regions were actually created in designtime (VS or Blend).

I am quite new to Prism and I thought that there was some mechanism so that the Shell (in this case) could show the views (associated with the regions ) by using d:DataContext given for the view.

In my (learning)App the region(s) are defined in the Shell.xaml (<ContentControl prism:RegionManager.RegionName="TheRegion"/>) and the RegionManager.RequestNavigate (Extension) method is executed within the IModule's Initialize() method.

Anyway, it would have been a nice feature if possible though, but perhaps I do not know enough about the dynamics of regions/view associations and have silly wishes.
Feb 10, 2014 at 6:47 PM
Hi Eager,

Based on my understanding, the region content is unfortunately resolved dinamically at runtime. So the designer would not know which registered View you would want to see in Design time.

In addition to Damian's response, the following disscusion link talks about this same issue which I think you would find helpful:

Regarding Prism 4.2 you may find the latest changes available in the last release on the following CodePlex Download section:

Regards,

Gabriel Ostrowsky
https://blogs.southworks.net/gostrowsky