我正在显示一个带有 WebBrowser 控件的窗口。我希望窗户是无框的,所以我设置了 WindowStyle="None" 这有效但在窗户周围显示彩色边框。Allowstransparency="true" 删除此但 WebBrowser 不再显示(按钮是)
我找到了http://www.neowin.net/forum/topic/646970-c%23-wpf-window-with-transparency-makes-windowsformshost-disappear/但我无法让它工作(SetWindowsLong 参数错误)
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>