質問

I have an application with various modules.

I have divided my main shell (xaml) into different regions and now I can load modules on those regions.

But I have requirement where in on click of some button I have to open a new window and then a new module will load on the new window.

I created a new window and I am opening that window , but the window is having a region which the RegionManager of main application does not recognize.

How do I load a module on a region which is not on main window but on child window ?

役に立ちましたか?

解決

You can find a quick sample solution for your problem in the following SkyDrive public folder as "RegionInChildWindowWithNavigation":

Based on my understanding, the problem you mentioned would be related on setting the RegionManager property on the ChildWindow View that cause the defined ModalWindowRegion be reachable from the RegionManager. Below is the ModalDialog ChildWindow view constructor from the aforemention sample. Notice that it also adds an event handler to properly remove all the views in the ChildWindow when closed.

[ImportingConstructor]
public ModalDialog(IRegionManager rm)
{
     this.rm = rm;
     this.SetValue(RegionManager.RegionManagerProperty, rm);
     InitializeComponent();
     this.Closed += new EventHandler(WindowsView_Closed);
}

void WindowsView_Closed(object sender, EventArgs e)
{
      while (rm.Regions["ModalWindowRegion"].Views.Count() > 0)
      {
           rm.Regions["ModalWindowRegion"].Remove(rm.Regions["ModalWindowRegion"].Views.FirstOrDefault());
      }
}

Then, you would just need to RequestNavigate() to the specified Region which is defined in the ChildWindow view from the RegionManager as follows:

 ModalDialogWindow.Show();
 rm.RequestNavigate("ModalWindowRegion", new Uri("HelloWorldView", UriKind.Relative));

In addition, you may find useful the following CodePlex threads:

I hope this helps.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top