C#WPF显示在窗口的WebBrowser与ALLOWTRANSPARENCY ="真"不显示 [英] C# WPF Displaying WebBrowser on window with AllowTransparency="true" does not display
问题描述
我显示上有一个WebBrowser控件的窗口。
我想要的窗口是无框的,所以我已经设置WindowStyle =无
这工作,但显示在窗口彩色边框。
Allowstransparency =真删除此,但不再显示在web浏览器(按钮)
我发现的 http://www.neowin.net/forum/topic/ 646970-C%23 WPF的窗口与透明度,使得-windowsformshost-消失/ 但我不能让它工作(SetWindowsLong参数错误)
窗口x:类=ZoomBrowserWPF.WebWindow
的xmlns =http://schemas.microsoft.com/winfx/2006/xaml/presentation
的xmlns :X =http://schemas.microsoft.com/winfx/2006/xaml
的xmlns:地方=CLR的命名空间:UMenu
标题=测试HEIGHT =605宽=700ResizeMode =CanResizeWithGrip
加载=Window_Loaded卸载=Window_Unloaded
WindowStyle =无
背景=透明
左=1 TOP =1
UseLayoutRounding =真时,SizeChanged =Window_SizeChanged>
< BORDER NAME =WindowBorderBorderBrush =黑了borderThickness =1CornerRadius =10背景=米色>
<网格和GT;
< Grid.RowDefinitions>
< RowDefinition高度=25/>
< RowDefinition高度=30/>
< RowDefinition />
< RowDefinition高度=33/>
< RowDefinition HEIGHT =25.5/>
< /Grid.RowDefinitions>
<电网X:NAME =GridWebBrowserGrid.Row =2Grid.RowSpan =2>
< web浏览器X:NAME =web浏览器Grid.ColumnSpan =2能见度=可见
保证金=0,0,-16,0
ScrollViewer.HorizontalScrollBarVisibility = 禁用
ScrollViewer.VerticalScrollBarVisibility =自动
ScrollViewer.IsDeferredScrollingEnabled =FALSE
ScrollViewer.CanContentScroll =FALSE
/>
< /网格和GT;
<按钮X:NAME =btnZoomInCONTENT =放大Grid.Row =1HEIGHT =23的HorizontalAlignment =左保证金=12,0,0,0VerticalAlignment = 顶级WIDTH =75点击=btnZoomIn_Click/>
<按钮X:NAME =btnZoomOutCONTENT =缩小Grid.Row =1HEIGHT =23的HorizontalAlignment =左保证金=168,0,0,0VerticalAlignment = 顶级WIDTH =75点击=btnZoomOut_Click/>
< TextBlock的Grid.Row =1HEIGHT =23的HorizontalAlignment =左保证金=102,0,0,0NAME =txtZoom文本=100VerticalAlignment =顶部 WIDTH =60/>
< /网格和GT;
< /边框>
< /窗GT;
我知道这是一个老问题,但我有完全相同今天同样的问题,我解决它使用
ResizeMode =NoResize
而不是
Allowstransparency =真
的
ResizeMode确实删除annoing边境太,不会影响WebBrowser控件。似乎是最简单的方法来解决你的问题在这种情况下:)
I am displaying a window with a WebBrowser control on it. I want the windows to be frameless so I have set WindowStyle="None" This works BUT displays a colored border around the window. Allowstransparency="true" removes this BUT the WebBrowser is no longer displayed (buttons are)
I have found http://www.neowin.net/forum/topic/646970-c%23-wpf-window-with-transparency-makes-windowsformshost-disappear/ BUT I cannot get it to work (SetWindowsLong Parameter error)
Window x:Class="ZoomBrowserWPF.WebWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:UMenu"
Title="Test" Height="605" Width="700" ResizeMode="CanResizeWithGrip"
Loaded="Window_Loaded" Unloaded="Window_Unloaded"
WindowStyle="None"
Background="Transparent"
Left="1" Top="1"
UseLayoutRounding="True" SizeChanged="Window_SizeChanged" >
<Border Name="WindowBorder" BorderBrush="Black" BorderThickness="1" CornerRadius="10" Background="Beige">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition Height="30"/>
<RowDefinition/>
<RowDefinition Height="33"/>
<RowDefinition Height="25.5"/>
</Grid.RowDefinitions>
<Grid x:Name="GridWebBrowser" Grid.Row="2" Grid.RowSpan="2">
<WebBrowser x:Name="webBrowser" Grid.ColumnSpan="2" Visibility="Visible"
Margin="0,0,-16,0"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.IsDeferredScrollingEnabled="False"
ScrollViewer.CanContentScroll="False"
/>
</Grid>
<Button x:Name="btnZoomIn" Content="Zoom in" Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="12,0,0,0" VerticalAlignment="Top" Width="75" Click="btnZoomIn_Click" />
<Button x:Name="btnZoomOut" Content="Zoom out" Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="168,0,0,0" VerticalAlignment="Top" Width="75" Click="btnZoomOut_Click" />
<TextBlock Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="102,0,0,0" Name="txtZoom" Text="100" VerticalAlignment="Top" Width="60" />
</Grid>
</Border>
</Window>
I know this is an old question but I had exactly the same problem today and I solved it using
ResizeMode="NoResize"
instead of
Allowstransparency="true"
The ResizeMode does remove the annoing border too and does not impact the WebBrowser control. Seems to be the easiest way to solve your problem in this case :)
这篇关于C#WPF显示在窗口的WebBrowser与ALLOWTRANSPARENCY ="真"不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!