我通过NuGet在我的应用程序中安装了CefSharp,然后在我的app.xaml.cs的OnStartup()
方法中初始化它。当我的应用程序运行时,什么都没有显示,也没有出现错误。将视图切换到另一个不使用CefSharp的视图会正常显示。我似乎无法让网页使用CefSharp渲染。
视图[QuestHTMLView]
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
</Grid.RowDefinitions>
<cefSharp:ChromiumWebBrowser Grid.Row="0" Address="https://github.com/cefsharp/CefSharp/wiki/Frequently-asked-questions" />
</Grid>
视图模型 [QuestHTMLViewModel]
public class QuestHTMLViewModel : Screen
{
}
ShellView(上一个视图呈现的位置)
<xctk:BusyIndicator VerticalAlignment="Top" Grid.Row="1" Grid.Column="0" Grid.RowSpan="2" IsBusy="{Binding IsBusy}">
<ContentControl x:Name="ActiveItem" />
</xctk:BusyIndicator>
ShellViewModel(其中 CefSharp 视图被设置为 ActiveItem)[仅构造函数]
public ShellViewModel()
{
QuestHTML = new QuestHTMLViewModel();
ActiveItem = QuestHTML;
}
初始化
protected override void OnStartup(StartupEventArgs e)
{
Cef.Initialize(new CefSettings());
base.OnStartup(e);
}