ここでの主な問題は、MVVM に適した方法で検索ポップアップを表示する方法です。私の github アカウントには、まさにこの目的のために設計されたカスタム コントロールの例があります (完全なソース コードをダウンロードできます)。
コントロールは次のように使用できます。
<c:ModalContentPresenter IsModal="{Binding DialogIsVisible}">
<!-- This is the main content e.g. your maintenance screen -->
<TabControl Margin="5">
<Button Margin="55"
Padding="10"
Command="{Binding ShowModalContentCommand}">
This is the primary Content
</Button>
</TabItem>
</TabControl>
<c:ModalContentPresenter.ModalContent>
<!-- This is the modal content e.g. your search popup -->
<Button Margin="75"
Padding="50"
Command="{Binding HideModalContentCommand}">
This is the modal content
</Button>
</c:ModalContentPresenter.ModalContent>
</c:ModalContentPresenter>
モーダル コンテンツは、プライマリ コンテンツ (この場合はメンテナンス画面) の上に直接表示され、その可視性はIsModal
、viewModel のプロパティにバインドできるプロパティによって制御されます。このプロパティは検索コマンドによって true に設定され、検索グリッドはメンテナンス画面の前に表示されます。
検索画面の「ビュー」には、プロパティを false に設定してポップアップ コンテンツを非表示にする別の ICommand オブジェクトにバインドされた閉じるボタンがあります。
プライマリ コンテンツとモーダル コンテンツの両方が同じコントロールによって管理されるため、情報を「渡す」必要がないことに注意してDataContext
ください。この場合、viewModel への参照となる同じものを共有します。