0

<Window>タイプ のオブジェクトのリストに追加できる添付プロパティを作成しましたFooBase。正常に機能しますが、問題は、これらの項目を依存性注入システム (DI) にリンクしたいことです。すべてFooが DI から取得されるか、作成されたそれぞれがFooDI に追加されます。

Ninjectでの依存性注入

Bind<IFoo1>().To<Foo1>.InSingletonScope();
Bind<IFoo2>().To<Foo2>.InSingletonScope();
Bind<IFoo3>().To<Foo3>.InSingletonScope();

XAML

<Window ...>
   <xx:Host.Foos>
      <Foo1 ... />
      <Foo2 ... />
      <Foo3 ... />
   </xx:Host.Foos>
   ...
</Window>

どのようにできるようになりたいか

class MainWindowViewModel
{
   // The same instance of IFoo1 as in the XAML code.
   public MainWindowViewModel(IFoo1 foo1)
   {}
}
4

0 に答える 0