WPF Prism - use regions with a scope or not?

I have a WPF project based on the release of Prism Feb 2009, configured as:

Shell provides one ContentControl as "MainRegion", Another view (user control) defined in an infrastructure project called SplitView provides two more areas "LeftRegion" and "RightRegion" as well as ContentControl.

Some of my application modules should display their view in MainRegion (one user control), while others should display their views (two user controls separately) in LeftRegion and RightRegion.

I tried to use areas with scope, believing that certain controllers would refer to regions with scope. Thus, basically every controller interested in SplitView functionality needs to create a new SplitView (user control) and activate it in MainRegion, while simultaneously activating its two custom controls in LeftRegion and RightRegion of the newly created areas of the SplitView area.

I am using MVVM with View Injection to display views.

Needless to say, something went horribly with this approach.

At runtime, I get this exception: "An exception occurred while creating a region called" LeftRegion. "Exception: System.InvalidOperationException: the specified element is already a logical child of another element. First disable it."

Do I correctly assume that LeftRegion and RightRegion try to register in the main RegionManager every time I create an instance of SplitView?

Sorry for the confusing / detailed message. Any suggestions? Best practices for achieving this?

Thanks in advance,

Ali

+3
source share
1 answer

" ..." - , , - , , , - .

:

    m_scopedRegionName = Guid.NewGuid().ToString(); /* EXAMPLE ! */
    m_scopedRegionManager =  m_regionManager.Regions[RegionNames.WORKSPACE_REGION].Add(myViewModel.View, m_scopedRegionName, true);
    m_someThingRegion = m_scopedRegionManager.Regions[RegionNames.SOME_THING_REGION];

"m_someThingRegion".

+2

Source: https://habr.com/ru/post/1719293/


All Articles