0

I'm building a WPF application using WPF UI. In my MainWindow, I have a NavigationView that loads pages when menu items are clicked. One of these pages contains a WebView, and that page has a button that triggers a custom dialog through a ContentPresenter defined in the MainWindow.

The problem:

The custom dialog appears behind the WebView. This only happens on pages containing the WebView; other pages work fine. MainWindow.xaml (Simplified)

<ui:FluentWindow ...>
    <Grid>
        <ui:NavigationView
            x:Name="NavigationView"
            SelectionChanged="OnNavigationSelectionChanged">
            <ui:NavigationView.ContentOverlay>
                <Grid>
                    <ui:SnackbarPresenter x:Name="SnackbarPresenter" />
                </Grid>
            </ui:NavigationView.ContentOverlay>
        </ui:NavigationView>

        <!-- Global dialog container -->
        <ContentPresenter x:Name="RootContentDialog" Grid.Row="0" />
    </Grid>
</ui:FluentWindow>

WebViewPage.xaml (Loaded into Navigation)

<Grid>
    <WebView x:Name="MyWebView" />
    <Button Content="Open Dialog" Click="OnOpenDialogClicked" />
</Grid>

Code-Behind (Button Click)

private void OnOpenDialogClicked(object sender, RoutedEventArgs e)
{
    RootContentDialog.Content = new MyCustomDialog();
    RootContentDialog.Visibility = Visibility.Visible;
}

It looks like the WebView is hosted in a separate HWND, causing the dialog to stay behind.

👉 How can I ensure my custom dialog appears on top of the WebView without changing it to a separate window?

Any help or workarounds would be appreciated! Below is sample window enter image description here

4
  • The content presenter is redundant because you're loading content on the fly. Might just as well add the UC to the Grid (which might help with "focus"). Add / remove. and no worries about "visibility". Commented Mar 22 at 17:12
  • @GerrySchmitz - i have added UC to grid and still it is showing behind only Commented Mar 23 at 3:35
  • stackoverflow.com/q/54829768/1136211 Commented Mar 23 at 8:58
  • stackoverflow.com/q/79489247/1136211 Commented Mar 23 at 9:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.