最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - WPF UI ContentPresenter Dialog Appears Behind WebView Loaded from Navigation - Stack Overflow

programmeradmin1浏览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.

发布评论

评论列表(0)

  1. 暂无评论