4

メソッドの使用中に問題が発生しました

this.regionManager.RegisterViewWithRegion("TextRegion", typeof(TextView));

上記のコードを何らかの方法でブートストラッパーに記述した場合。コードからregionmanagerのオブジェクトを取得できないため、機能しません

IRegionManager manager = this.Container.Resolve<IRegionManager>();

上記のコードは例外をスローします「例外メッセージは次のとおりです:現在のビルド操作(ビルドキーBuild Key [Microsoft.Practices.Composite.Regions.IRegionManager、null])が失敗しました:現在のタイプMicrosoft.Practices.Composite.Regions.IRegionManagerはインターフェイスであり、構築できません。タイプマッピングがありませんか?」

しかし、上記のコードは機能します。それをいくつかのViewModelに入れ、その中にIRegionManagerを挿入します。

お気に入り

 public HeaderControlViewModel(IEventAggregator aggregator, IRegionManager regionManager)
        : base(aggregator)
    {
        this.regionManager = regionManager;
        this.regionManager.RegisterViewWithRegion("TextRegion", typeof(TextView));
    } 

しかし、私はこれをしたくありません。すべてをブートストラッパーのみで構成したい。

bootstrapperがRegionManagerオブジェクトを取得できない理由を教えてください。どうすればこの問題を解決できますか?

よろしくお願いします...

4

1 に答える 1

-1

//...App.xaml.cs

   public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            Bootstrapper bs = new Bootstrapper();
            bs.Run();
            bs.ShowDefault();
        }
    }

//... Bootstrapper.cs

public void ShowDefault()
{
   RegionManager.GetRegionManager(Application.Current.MainWindow)
.RequestNavigate("MainRegion", "ViewA");
}

//...

于 2016-11-04T20:49:05.483 に答える