WPFにおけるPrism集中講座(6) EventAggregatorとregionを使う
14-UsingEventAggregator Description には Using the IEventAggregator とあります。 まんま過すぎですね。 動かしてみると、TextBox に入力した内容を「Send Message」で送ると、 ListBox に追加されるというサンプルのようです。 UsingEventAggregator 内の App.xaml.cs using System.Windows; using UsingEventAggregator.Views; namespace UsingEventAggregator { /// <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) { } protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog) { moduleCatalog.AddModule<ModuleA.ModuleAModule>(); moduleCatalog.AddModule<ModuleB.ModuleBModule>(); } } } UsingEventAggregator 内の Views\MainWindow.xaml <Window x:Class="UsingEventAggregator.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="{Binding Title}" Width="525" Height="350" prism:ViewModelLocator.AutoWireViewModel="True"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition /> </Grid.ColumnDefinitions> <ContentControl prism:RegionManager.RegionName="LeftRegion" /> <ContentControl Grid.Column="1" prism:RegionManagerRegionName="RightRegion" /> </Grid> </Window> UsingEventAggregator 内の ViewsModels\MainWindowViewModel.cs namespace UsingEventAggregator.ViewModels { public class MainWindowViewModel : BindableBase { private string _title = "Prism Unity Application"; public string Title { get { return _title; } set { SetProperty(ref _title, value); } } public MainWindowViewModel() { } } } ModuleA プロジェクトと ModuleB プロジェクトを ContentControl で読み込んでいるようです。 ...