开发者

Help needed with Microsoft Prism application

开发者 https://www.devze.com 2023-03-14 11:57 出处:网络
I\'m creating a new Prism4 application with MEF and it works nice. I\'ve created the Shell, etc and everything is OK.

I'm creating a new Prism4 application with MEF and it works nice. I've created the Shell, etc and everything is OK.

But now I need to create a new Window with a Region inside it but it seems like the region is not registered with the RegionManager (see the Window_Closing event) and the Region in the window work well because the views injected into it are shown.

Here's the code for the new Window

Wizard.xaml

<DockPanel LastChildFill="True">
  <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" DockPanel.Dock="Bottom">
    <Button Content="_Previous" Margin="0, 0, 10, 0" /> 
    <Button Content="_Next" /> 
  </StackPanel> 
  <ContentControl cal:RegionManager.RegionName="WizardStepsRegion" /> 
</DockPanel>

When I try to get the window's Region I get the following exception "KeyNotFoundException was unhandled by user code", "The region manager does not contain the WizardStepsRegion region."

Wizard.xaml.cs

private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{ 
  object asdf = regionManager.Regions["WizardStepsRegion"]; 
}

Why t开发者_如何转开发he region is not registered in the region manager?

Can someone help me?

Thank you.


It sounds like you are trying to create a dialog. Are you Importing that dialog or creating it with new Wizard()? If you are creating it with the new operator, the RegionManager won't know anything about it. You can manually tell the RegionManager about the window using SetRegionManager.

RegionManager.SetRegionManager(window, myRegionManager);

Then the RegionManager will know all about your type, discover its regions, etc. The other option is to Import the Wizard type and just .Show() it when you want, but sometimes this isn't practical.

0

精彩评论

暂无评论...
验证码 换一张
取 消