WPF嵌入一个chrome浏览器,没有显示是怎么回事?

WPF代码

<Window x:Class="WpfApp2.MainWindow"
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:wpf="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
xmlns:cef="clr-namespace:CefSharp;assembly=CefSharp.Core"
xmlns:local="clr-namespace:WpfApp2"
mc:Ignorable="d"
Title="使用Chrome浏览器" Height="450" Width="800">
<Grid Name="grid1">
<wpf:ChromiumWebBrowser x:Name="browser" Address="http://www.baidu.com" />
</Grid>
</Window>

运行之后,什么都没有显示,一片空白,感觉象是被隐藏了,或者完全透明了一样

回答

我测试了一下,.netframework4.6 使用cefsharp.wpf 97.1.61,正常可以显示网页。

有可能你没有安装vc++分发库吧,
去这里下载最新的安装一下
https://docs.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist?view=msvc-170

要仔细阅读一下github上的doc,地址是https://github.com/cefsharp/CefSharp/wiki/
nuget安装CefSharp.Wpf后会弹出一个readme,可以阅读一下。

还有就是看看visual studio的output窗口里的输出内容,通常会有一些有用的信息。

以上是WPF嵌入一个chrome浏览器,没有显示是怎么回事?的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>