LoginSignup
0
1

More than 3 years have passed since last update.

Prism コードサンプル学習:02-Regions

Posted at

Prism コードサンプル学習:02-Regions

はじめに

以下の記事の続きです。
https://qiita.com/mngreen/items/49767e120292896d3937

02-Regions

本サンプルではRegionManagerクラスを用いて、領域に名称を与えるサンプルのようです。

<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)
        {
        }
    }

ポイントとしては以下でしょうか。

  • 前回はBootstrappprを利用していたが、そのBootstrapperを隠蔽するPrismApplicationクラスが利用されている
    • PrismApplicationの基底クラスはこちら
  • MainWindowでは、ContentControlコントロールに添付プロパティであるRegionManager.RegionNameプロパティに"ContentRegion"がセットされている
  • 名前が設定されると、その領域を指定して画面遷移させられることができる

おわりに

今回はRegionManagerクラスのソースコードを読み、領域に名前を付ける方法が分かりました。
所感ですが、領域にRegionManagerを経由させて名前を定義し、コンテンツを色々登録しておけば後からビューをどんどん追加することもできそうです。
次回、03-CustomRegionsについて見ていこうと思います。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1