CefSharp For WPF基本使用

简介: 原文:CefSharp For WPF基本使用Nuget引用 CefSharp.Wpf CefSharp.Common cef.redist.x64 cef.redist.x86 直接搜索安装CefSharp.
原文: CefSharp For WPF基本使用

Nuget引用

CefSharp.Wpf
CefSharp.Common
cef.redist.x64 cef.redist.x86 

直接搜索安装CefSharp.Wpf即可,因为CefSharp.Wpf依赖于其他三个包,所以会自动安装四个包

 

 

先更改设置

指定特定的平台,x64或者x86,默认是Any CPU
不进行配置的话,CefSharp是不支持Any CPU的

 

 

WPF写法

xmlns:cefSharpWPF="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
<cefSharpWPF:ChromiumWebBrowser Address="url"></cefSharpWPF:ChromiumWebBrowser> 

Any CPU的支持

using System.Windows;
using System;
using System.Runtime.CompilerServices;
using CefSharp;
using System.IO; using System.Reflection; using System.Windows.Threading; using CefSharpWpfDemo.Log; namespace CefSharpWpfDemo { /// <summary> /// Interaction logic for App.xaml /// </summary> public partial class App : Application { public App() { // Add Custom assembly resolver AppDomain.CurrentDomain.AssemblyResolve += Resolver; //Any CefSharp references have to be in another method with NonInlining // attribute so the assembly rolver has time to do it's thing. InitializeCefSharp(); } [MethodImpl(MethodImplOptions.NoInlining)] private static void InitializeCefSharp() { var settings = new CefSettings(); // Set BrowserSubProcessPath based on app bitness at runtime settings.BrowserSubprocessPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, Environment.Is64BitProcess ? "x64" : "x86", "CefSharp.BrowserSubprocess.exe"); // Make sure you set performDependencyCheck false Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: null); } // Will attempt to load missing assembly from either x86 or x64 subdir // Required by CefSharp to load the unmanaged dependencies when running using AnyCPU private static Assembly Resolver(object sender, ResolveEventArgs args) { if (args.Name.StartsWith("CefSharp")) { string assemblyName = args.Name.Split(new[] { ',' }, 2)[0] + ".dll"; string archSpecificPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, Environment.Is64BitProcess ? "x64" : "x86", assemblyName); return File.Exists(archSpecificPath) ? Assembly.LoadFile(archSpecificPath) : null; } return null; } } } 

相关资料

https://github.com/cefsharp/CefSharp/issues/1714

示例代码

https://github.com/zLulus/NotePractice/tree/dev3/WPF/CefSharpWpfDemo

官方资料

https://www.codeproject.com/Articles/881315/Display-HTML-in-WPF-and-CefSharp-Tutorial-Part
https://github.com/cefsharp/CefSharp/wiki/Quick-Start
http://cefsharp.github.io/

目录
相关文章
|
C# Windows
wpf怎么使用WindowsFormsHost(即winform控件)
原文:wpf怎么使用WindowsFormsHost(即winform控件) 使用方法:   1、首先,我们需要向项目中的引用(reference)中添加两个动态库dll,一个是.
5041 0
|
7月前
|
C#
WPF使用Blazor的快速案例
WPF使用Blazor的快速案例
86 0
WPF使用Blazor的快速案例
|
Shell C# 调度
WPF PRISM开发入门一( 初始化PRISM WPF程序)
原文:WPF PRISM开发入门一( 初始化PRISM WPF程序) 这篇博客将介绍在WPF项目中引入PRISM框架进行开发的一些基础知识。目前最新的PRISM的版本是Prism 6.1.0,可以在Github上获取PRISM的源码。
3616 0
|
C# Windows
使用WPF来创建 Metro UI程序
原文:使用WPF来创建 Metro UI程序 这个是我以前网上看到的一篇文章,原文地址是:Building a Metro UI with WPF,这篇文章一步步的介绍了如何实现一个Metro样式的窗口,并且效果非常好。
1229 0
|
C#
WPF中StringFormat的用法
原文:WPF中StringFormat的用法 WPF中StringFormat的用法可以参照C#中string.Format的用法 1、 C#中用法: 格式化货币(跟系统的环境有关,中文系统默认格式化人民币,英文系统格式化美元)示例: string.
4078 0
|
API C# Windows
实现一个 WPF 版本的 ConnectedAnimation
原文:实现一个 WPF 版本的 ConnectedAnimation 版权声明:本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。欢迎转载、使用、重新发布,但务必保留文章署名吕毅(包含链接:http://blog.csdn.net/wpwalter/),不得用于商业目的,基于本文修改后的作品务必以相同的许可发布。
966 0
|
前端开发 JavaScript C#
WPF中使用cefsharp
原文:WPF中使用cefsharp 新入职一家公司,由写服务端接口变成了软硬件通信、服务器、客户端、C/S、B/S乱七八糟各种打杂。
1970 0
|
JavaScript C#
wpf CefSharp 与 js交互
原文:wpf CefSharp 与 js交互 通过 NuGet 获取 CefSharp.WpF 组件。  xmlns:cefSharp="clr-namespace:CefSharp.
3829 0
|
C# UED
WPF 使用DMSkin for WPF 快速搭建漂亮的WPF程序
原文:WPF 使用DMSkin for WPF 快速搭建漂亮的WPF程序 DMSkin-for-WPF是一个基于WPF的.Net WPF开源界面库,实现了无边框的WPF开发方案,内置部分控件模板. 你可以参照模板自行修改完善。
1994 0
|
C# 容器
WPF命令
原文:WPF命令 “有了路由事件为什么还需要命令系统呢?”。事件的作用是发布、传播一些消息,消息传达到了接收者,事件的指令也就算完成了,至于如何响应事件送来的消息事件并不做任何限制,每个接收者可已用自己的行为来响应事件。
805 0

热门文章

最新文章