Search code examples
c#wpfmvvmcontentpresenter

Is there any reason I shouldn't use two ContentPresenters on top of each other to emulate a pop up window?


For example:

    <Viewbox>
        <ContentPresenter Content="{Binding CurrentView}" />
    </Viewbox>

    <!--This is the popup presenter, which overlays the whole screen and displays a popup when one is active-->
    <Viewbox>
        <ContentPresenter Content="{Binding PopUpView}" />
    </Viewbox>
</Grid>

Then, the view in PopUpView will have a Border in the middle with the message to be displayed and a semi-transparent background to make it appear like the original view is out of focus. Is there any reason to avoid this approach?


Solution

  • Surely the answer is because there is already a Popup class which is designed to handle exactly this situation, including all the focus issues, etc, that you are likely to face?