Prism code sample learning: 02-Regions

1 minute read

Prism code sample learning: 02-Regions

Introduction

This is a continuation of the following article.
https://qiita.com/mngreen/items/49767e120292896d3937

02-Regions

In this sample, it seems to be a sample that gives a name to a region using the RegionManager class.

<Window x:Class="Regions.Views.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:prism="http://prismlibrary.com/"
        Title="Shell" Height="350" Width="525">
    <Grid>
        <ContentControl prism:RegionManager.RegionName="ContentRegion" />
    </Grid>
</Window>
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : PrismApplication
    {
        protected override Window CreateShell()
        {
            return Container.Resolve<MainWindow>();
        }

        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {
        }
    }

Is it the following as a point?

–Last time, Bootstrapppr was used, but the PrismApplication class that hides the Bootstrapper is used.
–The base class of PrismApplication is here
–In MainWindow, “ContentRegion” is set in the RegionManager.RegionName property, which is an attached property to the ContentControl control.
–RegionManager is here [https://github.com/PrismLibrary/Prism/blob/master/src/Wpf/Prism.Wpf/Regions/RegionManager.cs)
–Once the name is set, you can specify the area and change the screen.
–The simplest to use RequestNavigate () method
–The content specified by URI is displayed in the regionName specified by the argument.
-See also Qiita article

in conclusion

This time I read the source code of the RegionManager class and found out how to name the region.
It seems that you can add more views later by defining the name in the area via RegionManager and registering various contents.
Next time, I’ll look at 03-Custom Regions.