简体   繁体   English

如何在弹出窗口中显示 web 浏览器顶部的进度条?

[英]How to display progress bar on top of the web browser in a popup?

I have a web browser and progress bar in a parent popup control.我在父弹出控件中有一个 web 浏览器和进度条。 When the application is not running, in the design view the progress bar is being shown on top of the web browser, but as soon as the application runs the progress bar goes behind web browser.当应用程序未运行时,在设计视图中,进度条显示在 web 浏览器的顶部,但一旦应用程序运行,进度条就会出现在 web 浏览器的后面。 I have tried using the ZIndex also, but in vain.我也尝试过使用 ZIndex,但徒劳无功。

Please help me with this because I have this requirement that when the content is being loaded in web browser, the progress bar should be shown at the top of blank web browser.请帮我解决这个问题,因为我有这个要求,当在 web 浏览器中加载内容时,进度条应显示在空白 web 浏览器的顶部。

Code is something of this sort:代码是这样的:

<Grid>
    <Popup
        IsOpen="True"
        StaysOpen="True"
        Placement="Center"
        Height="100"
        Width="200">
        <Border>
            <Grid>
                <WebBrowser
                    Grid.ZIndex="1"
                    Visibility="Visible"
                    Margin="10"
                    Source="D:\Temp\gui1_Help.html">
                </WebBrowser>
                
                <ProgressBar 
                    Grid.ZIndex="2"
                    Height="50"
                    Visibility="Visible"
                    IsIndeterminate="True"
                    >

                </ProgressBar>
            </Grid>
        </Border>
    </Popup>

</Grid>

This image shows progress bar on top of web browser (When the application is not running):此图像显示 web 浏览器顶部的进度条(当应用程序未运行时):

此图像显示 Web 浏览器顶部的进度条(当应用程序未运行时)。

This image shows progress bar goes behind web browser (When the application is running):此图像显示进度条在 web 浏览器后面(应用程序运行时): 此图像显示 Web 浏览器顶部的进度条(当应用程序未运行时)。

Unfortunately, the WPF WebBrowser control is actually just a wrapped version of the WinForms control.不幸的是,WPF WebBrowser 控件实际上只是 WinForms 控件的包装版本。

See: Make WPF control over the web browser请参阅: 使 WPF 控制 web 浏览器

See: Is there a way to render WPF controls on top of the wpf WebBrowser control?请参阅: 有没有办法在 wpf WebBrowser 控件之上呈现 WPF 控件?

And due to the rendering order of WPF, WinForms will always be rendered on top of WPF controls.由于 WPF 的呈现顺序,WinForms 将始终呈现在 WPF 控件之上。

You have two options:你有两个选择:

  1. Go with a 3rd party WPF control (to avoid WinForms altogether), such as CESSharp . Go 与第 3 方 WPF 控件(完全避免 WinForms),例如CESSharp
  2. Place your progress bar inside of a new Window that has WindowStyle=None and sized to just the progress bar, and place it on top of your browser.将你的进度条放在一个新的 Window 里面,它有 WindowStyle=None 并且大小只有进度条,然后把它放在你的浏览器的顶部。 The huge downside to this is maintaining the window position if your browser or main window is resized.如果您的浏览器或主 window 被调整大小,那么最大的缺点是保持 window position。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM