WPF Prism 7.0+ IRegionManager(区域)

源码下载:PrismCore.zip

创建区域模块:

 

示例结果:

MainWindow.xaml 调用区域模块:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="28"/>
        <RowDefinition Height="*"/>
        <RowDefinition Height="28"/>
    </Grid.RowDefinitions>
    <ContentControl Grid.Row="0" prism:RegionManager.RegionName="HeaderRegin" x:Name="Header"/>
        
    <ContentControl Grid.Row="2" prism:RegionManager.RegionName="FooterRegin" x:Name="Footer"/>
</Grid>

 MainWindow.cs 注册模块:

RegionManager.SetRegionName(Header, "HeaderRegin");
regionManager.RegisterViewWithRegion("HeaderRegin", typeof(Regions.HeaderControl));
RegionManager.SetRegionName(Footer, "FooterRegin");
regionManager.RegisterViewWithRegion("FooterRegin", typeof(Regions.FooterControl));

 

posted @ 2024-07-02 17:11  microsoft-zhcn  阅读(13)  评论(0编辑  收藏  举报