I found a lot questions regarding regions inside data templates that lead to the following link [Prism 5] RegionName in ItemsControl DataTemplate
The information there is really helpful but it dose not really answer why regions don't get created by simply having a dynamic region name.
Say I have a view and a ViewModel as follows
View:
<StackPanel>
<ContentControl prism:RegionManager.RegionName="Region1"/>
<ContentControl prism:RegionManager.RegionName="{Binding Region2}"/>
</StackPanel>
ViewModel:
public ViewModel()
{
Region2 = "Region2"
}
public string Region2 {get; set;}
In this scenario the RegionManager will only know about the "region1" region. If i tried to activate the content for region2 it would give me an error saying that region2 does not exists. Neither region is refined inside a weird control or data template.
How can I get the regionManager to create region2 while using bindings?