1

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.

Erik Philips
  • 53,428
  • 11
  • 128
  • 150
senz
  • 879
  • 10
  • 25
  • My goal is just to load an module in a new window. It's just like a tool library. There are many tools with it own views services and so on. In my main program i had only a button "open xyz-plugin" to run this module. This works really fine in my shell (just a content-control with a specified region). But I want to run the module in a new window, thats my problem – senz Dec 18 '17 at 17:12

1 Answers1

1

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>
Rickless
  • 1,377
  • 3
  • 17
  • 36
  • thats exactly what I am looking for, thank you very much! – senz Dec 18 '17 at 17:36
  • I'm so sorry, I didn't read your question properly the first time. I should've read your question carefully and therefore answered your question earlier. – Rickless Dec 18 '17 at 17:37