0

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?

Adrian Garcia
  • 363
  • 3
  • 12
  • 2
    Actually binding RegionName works fine. Take for example https://github.com/PrismLibrary/Prism-Samples-Wpf/tree/master/17-BasicRegionNavigation and replace hard-coded region name by a binding to view model. It works. Thus, it is a problem with your application. – dvorn Oct 12 '17 at 08:13
  • A tip: use PresentationTraceSources.TraceLevel=High in your binding too see if it's correctly resolved. – Maciek Świszczowski Oct 12 '17 at 08:39

0 Answers0