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

I'm building a WPF application using WPF UI. In my MainWindow, I have a NavigationView that loads

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744307193a4567772.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信