WPF C#web浏览器滑过顶部菜单 [英] WPF c# webbrowser scrolls over top menu

查看:128
本文介绍了WPF C#web浏览器滑过顶部菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个菜单和ScrollViewer中内的网格。在ScrollViewer中我有一个组框与另一个网格和一个WebBrowser元素内。

现在,当我让我的窗口比我的web浏览器内容的内容更小,并且在ScrollViewer中向下滚动的问题出现了。任何事物都有保证金,使其保持低于顶部的菜单,但是web浏览器元素没有,因此覆盖了菜单。有没有办法解决这个问题的方法吗?我无法弄清楚:■页边距和放大器;垫不工作。我希望周围什么的网格元素会做的伎俩,但没有任何工程。

编辑:

好吧,我尝试添加的XAML code,但请记住这是疯狂巨大的,所以这是极端的短版:(网页浏览器元素是在code的底部)

 <窗​​口x:类=Cleaning_Masters_Official.MainWindow
        的xmlns =htt​​p://schemas.microsoft.com/winfx/2006/xaml/$p$psentation
        的xmlns:X =htt​​p://schemas.microsoft.com/winfx/2006/xaml
        标题=清洁大师Offerte包 - nieuw.offNAME =主WIDTH ={DynamicResource {X:静态SystemParameters.MaximizedPrimaryScreenWidthKey}}
        图标=BIN \\调试\\图像\\ Main.ico
    HEIGHT ={DynamicResource {X:静态SystemParameters.MaximizedPrimaryScreenHeightKey}}关闭=Main_Closing
    WindowStartupLocation =中心屏幕WindowStyle =SingleBorderWindow的WindowState =最大化>    <网格和GT;
        < Grid.RowDefinitions>
            < RowDefinition高度=22/>
            < RowDefinition高度=*/>
            < RowDefinition NAME =条棒HEIGHT =0/>
        < /Grid.RowDefinitions>        &所述;的ScrollViewer保证金=10Grid.Row =1>
            < TabControl的名称=tabChapters>                < TabItem的标题=AlgemeenNAME =tabGeneral>
                    <网格和GT;
                        < Grid.ColumnDefinitions>
                            &所述; ColumnDefinition宽度=*/>
                            &所述; ColumnDefinition宽度=*/>
                            &所述; ColumnDefinition宽度=*/>
                        < /Grid.ColumnDefinitions>
                        < Grid.RowDefinitions>
                            < RowDefinition高度=自动/>
                            < RowDefinition高度=*/>
                        < /Grid.RowDefinitions>                        <分组框标题=Configureer hoofdstukken:保证金=10填充=10>
                            <网格和GT;
                                ...
                            < /网格和GT;
                        < /分组框中>                        &所述;分组框中部首=Voorpagina Afbeeldingen:保证金=10,0,10,10填充=10Grid.Column =0Grid.Row =1Grid.ColumnSpan =2>
                            <电网VerticalAlignment =评出的>
                                ...
                            < /网格和GT;
                        < /分组框中>                        <分组框标题=Offerte信息:保证金=10,10,10,10填充=10Grid.Column =1Grid.Row =0>
                            <网格和GT;
                                ...
                            < /网格和GT;
                        < /分组框中>                        <分组框中保证金=0,10,10,10标题=Inhoudstafel:Grid.Column =2Grid.RowSpan =2>
                            <网格和GT;
                                < web浏览器保证金=10NAME =wbInhoudstafel/>
                            < /网格和GT;
                        < /分组框中>
                    < /网格和GT;
                < / TabItem的>                < TabItem的标题=1 VoorwoordNAME =tabVoorwoord>
                < / TabItem的>
                    ...
                < / TabItem的>
            < / TabControl的>
        < /&的ScrollViewer GT;        <菜单DockPanel.Dock =评出的NAME =顶部菜单>
            ...
        < /菜单>        &所述;状态条名称=SBARGrid.Row =2
            ...
        < /状态栏>
    < /网格和GT;
< /窗GT;


解决方案

在WPF WebBrowser控件基本上是旧的Win32 Web浏览器控件和WPF内容的上方技术上呈现。此外,它有一些严重的问题,与大小计算。

请参阅
http://msdn.microsoft.com/en-美国/库/ aa970688(v = vs.85)的.aspx

恐怕没有办法告诉WebBrowser控件来改变这种行为。

但也有另一种控制在那里:

HTTP://wpfchromium.$c$cplex.com/

http://awesomium.com/

编辑:

在这里找到SO上很好地概括它指出了一些备选方案:

<一个href=\"http://stackoverflow.com/questions/980334/wpf-webbrowser-3-5-sp1-always-on-top-other-suggestion-to-display-html-in-wpf\">WPF web浏览器(3.5 SP1)总是在最上层 - 其他建议,以显示在WPF HTML

I have a grid with a menu and a scrollviewer inside. In the scrollviewer i have a groupbox with another grid and inside a webbrowser element.

Now the problem arises when i make my window smaller than the content of my webbrowser content, and scroll down in the scrollviewer. Everything has a margin so it stays below the top menu, however the webbrowser element does not, hence covering the menu. Is there a way to solve this? I can't figure it out :s Margins & Paddings don't work. I was hoping the grid element around it or something would do the trick, but nothing works.

EDIT:

Ok I tried to add the xaml code but bear in mind it was insanely huge, so this is the extreme short version: (webbrowser element is at the bottom of the code)

<Window x:Class="Cleaning_Masters_Official.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Cleaning Masters Offerte Packet - nieuw.off" Name="Main"  Width="{DynamicResource {x:Static SystemParameters.MaximizedPrimaryScreenWidthKey}}"
        Icon="bin\Debug\Images\Main.ico"
    Height="{DynamicResource {x:Static SystemParameters.MaximizedPrimaryScreenHeightKey}}" Closing="Main_Closing"
    WindowStartupLocation="CenterScreen" WindowStyle="SingleBorderWindow" WindowState="Maximized">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="22" />
            <RowDefinition Height="*" />
            <RowDefinition Name="rowbar" Height="0" />
        </Grid.RowDefinitions>

        <ScrollViewer Margin="10" Grid.Row="1">
            <TabControl Name="tabChapters">

                <TabItem Header="Algemeen" Name="tabGeneral">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>

                        <GroupBox Header="Configureer hoofdstukken:" Margin="10" Padding="10">
                            <Grid>
                                ...     
                            </Grid>
                        </GroupBox>

                        <GroupBox Header="Voorpagina Afbeeldingen:" Margin="10,0,10,10" Padding="10" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2">
                            <Grid VerticalAlignment="Top">
                                ...     
                            </Grid>
                        </GroupBox>

                        <GroupBox Header="Offerte Info:" Margin="10,10,10,10" Padding="10" Grid.Column="1" Grid.Row="0">
                            <Grid>
                                ...     
                            </Grid>
                        </GroupBox>

                        <GroupBox Margin="0,10,10,10" Header="Inhoudstafel:" Grid.Column="2" Grid.RowSpan="2">
                            <Grid>
                                <WebBrowser Margin="10" Name="wbInhoudstafel"/>
                            </Grid>
                        </GroupBox>
                    </Grid>
                </TabItem>

                <TabItem Header="1. Voorwoord" Name="tabVoorwoord">
                </TabItem>
                    ...         
                </TabItem>
            </TabControl>
        </ScrollViewer>

        <Menu DockPanel.Dock="Top" Name="TopMenu">
            ...     
        </Menu>

        <StatusBar Name="sbar" Grid.Row="2"
            ...     
        </StatusBar>
    </Grid>
</Window>

解决方案

The WPF WebBrowser control is basically the old Win32 Webbrowser control and is technically rendered above the WPF content. Additionally it has some serious issues with size calculations.

See http://msdn.microsoft.com/en-us/library/aa970688(v=vs.85).aspx

I'm afraid there's no way to tell the WebBrowser Control to change that behavior.

But there are alternative controls out there:

http://wpfchromium.codeplex.com/

http://awesomium.com/

Edit:

Found a great summary here on SO which points to some alternatives:

WPF WebBrowser (3.5 SP1) Always on top - other suggestion to display HTML in WPF

这篇关于WPF C#web浏览器滑过顶部菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆