2011-03-17 93 views

回答

1

shell不知道要显示哪个视图。外壳只提供一个区域:

<Window x:Class="PCRS.Client.Shell" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:Regions="clr-namespace:Microsoft.Practices.Prism.Regions;assembly=Microsoft.Practices.Prism" > 
    <Grid> 
     <ContentControl Regions:RegionManager.RegionName="MainRegion"/> 
    </Grid> 
</Window> 

该模块具有注册着眼于区域应该在提交:

[Module(ModuleName="MyModule")] 
public class MyModule : IModule 
{ 
    public void Initialize() 
    { 
     RegionManager.RegisterViewWithRegion("MainRegion", typeof(MyView)); 
    } 
} 

的区域经理,现在需要将视图到指定的护理地区。

如果您在不同的应用中使用了两种观点,你才能MyView1注册到区域称为MyView1Region和MyView2的区域称为MyView2Region:

RegionManager.RegisterViewWithRegion("MyView1Region", typeof(MyView1)); 
RegionManager.RegisterViewWithRegion("MyView2Region", typeof(MyView2)); 

现在你可以通过在shell命名的区域决定哪些查看使用。

但我认为你不应该使用PRISM或者你应该重新考虑你的设计。 PRISM被用来解耦应用程序模块,并且没有唯一知道整个应用程序组成的Shell。使用PRISM,您可以让模块决定在用户​​界面中输入视图的位置。只要你想让这个决定权仍然在shell里面,你就不需要PRISM。您更可能使用标准的MVVM模式。

相关问题