Open module in new window

544 Views Asked by At

I try to open a module resolved by a special directory

return new DirectoryModuleCatalog() { ModulePath = @"..\..\modules" };

and want to show it in a new Window.

How can I do that?

My approach so far:

public void OpenInNewWindow(string regionName)
{
    var cc = new ContentControl();
    _regionManager.RegisterViewWithRegion(regionName, () => cc);

    new Window
    {
        Content = cc
    }.Show();
}

But that seems not to work. My Window is empty.

1

There are 1 best solutions below

2
On BEST ANSWER

Assuming that you are dealing with navigation and this line:

var cc = new ContentControl();

Is for demonstration only. I guess you should add a region name to the content control before assigning it to the view or before calling RegisterViewWithRegion, like this.

var contentControl = new ContentControl();
RegionManager.SetRegionName(contentControl, regionName);
var window = new Window
{
    Content = contentControl
}.Show();

RegionManager.SetRegionName is an attached property, which is equivalent to:

<ContentControl regions:RegionManager.RegionName="MyRegion"></ContentControl>