Window
ではなく言及しているので、WPFを想定していますChildWindow
が、一般的には作成したいと考えていますUserControls
。
WindowManager
を呼び出すかどうかに基づいて、コンテンツが適切なコンテナーに表示されることを自動的に保証しますShowPopup
。ShowDialog
またはShowNotification
、それらを UC にすることで、物事が少し柔軟になります (実際にWindowManager
は、WPF アプリの初期ウィンドウを設定し、ブートストラップが開始する ViewModel のビューを解決します)。ビューがまだウィンドウでない場合は、ウィンドウが作成されるようにします)
複合ビューに関しては、サブビュー モデルをコンポジション コンテナー (つまり、それらをホストする別のビュー モデル) のプロパティとして含め、ContentControl
および CM 規則を使用してそれらをバインドするだけです。
たとえば、2 つの UC を表示する VM は次のようになります。
public class SomeCompositeViewModel : Screen
{
public SomeOtherViewModel SomeOtherView { get; set; } // You probably want INPC here as per usual
public YetAnotherViewModel YetAnotherView { get; set; }
public SomeCompositeViewModel()
{
// Setup as you need - direct instantiation, IoC/DI, use MEF, whatever works for you
SomeOtherView = new SomeOtherViewModel();
YetAnotherView = new YetAnotherViewModel();
}
}
および XAML
<UserControl x:Class="SomeAssembly.Yadda.Yadda.SomeComposititeViewModel">
<StackPanel>
<!-- Bind to SomeOtherViewModel via the SomeOtherView property etc -->
<ContentControl x:Name="SomeOtherView" />
<ContentControl x:Name="YetAnotherView" />
</StackPanel>
</UserControl>
(レイアウトでもう少しクリエイティブになりませんか!)
すべてのアイテムにライフサイクルを持たせたい場合は、そのまま使用できますConductor<T>.Collection.AllActive
が、ツール ウィンドウではなく複合ビューを探しているように思えます。