How to place a WebBrowser control below other controls?

别来无恙 提交于 2019-12-11 08:56:58

问题


I tried setting the Canvas.ZIndex property, but when I scroll, the HTML in the webBrowser control still floats above the menu bar in the Silverlight navigation application.

You can see the sample code below:

I just created an empty Silverlight Navigation Application and added the following in Home.XAML:

<navigation:Page x:Class="Test.Home" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
    Title="Home"
    Style="{StaticResource PageStyle}" Canvas.ZIndex="1">

    <Grid x:Name="LayoutRoot">
        <ScrollViewer x:Name="PageScrollViewer" Style="{StaticResource PageScrollViewerStyle}">

            <StackPanel x:Name="ContentStackPanel">

                <TextBlock x:Name="HeaderText" Style="{StaticResource HeaderTextStyle}" 
                                   Text="Home Content"/>
                <TextBlock x:Name="lblInstructions" Style="{StaticResource ContentTextStyle}" 
                                   Text="Instructions "/>
                <WebBrowser Name="HTMLContent" Height="850" Width="600" Canvas.ZIndex="0" />
                <TextBlock x:Name="lblScribble" Style="{StaticResource ContentTextStyle}" 
                                   Text="Scribble here "/>
                <InkPresenter Name="inkPresenter1" DataContext="{Binding}" Cursor="Stylus" Opacity="1" />
            </StackPanel>

        </ScrollViewer>
    </Grid>

And then set the HTML content in the code behind:

HTMLContent.NavigateToString("<p>Some HTML</p>");

When I scroll down, the HTML content goes above the navigation at the top. That tells me the webBrowser control is above the rest of the controls. But setting the Canvas.ZIndex isn't doing anything.


回答1:


This is a common "airspace issue", which is similar to the WPF airspace issue. There isn't currently a way to make it appear behind your other Silverlight content.

(For the first link search for "airspace" to find the related info).



来源:https://stackoverflow.com/questions/6492220/how-to-place-a-webbrowser-control-below-other-controls

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!