1 按照《prism搭建项目》搭建好项目
2 在Views目录中添加用户控件ViewA
<UserControl x:Class="ViewDiscovery.Views.ViewA"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ViewDiscovery.Views"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<TextBlock Text="View A" FontSize="38" />
</Grid>
</UserControl>
3 在MainWindow的构造函数中注入IRegionManager,并通过其为Region注册视图
public MainWindow(IRegionManager regionManager)
{
InitializeComponent();
//view discovery
regionManager.RegisterViewWithRegion("ContentRegion", typeof(ViewA));
}
4 运行