AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
26.19k stars 2.27k forks source link

About webview,render html in avalonia application. #4638

Closed wuzlai closed 2 years ago

wuzlai commented 4 years ago

Hi : Hello,I have a problem that maybe you once had, I have some html,just to render in the avalonia application. I have find a way,it is cefnet. it use google chrome,but this will make the package very large,what is more ,the cefnet must be synchronized with the latest version of Avalonia.now i only use it in avalonia 0.9.12.but in 0.10.0 preview5 failed. Are there any solutions that have been successfully applied in the project?I would like to ask you how did you solve the problem? thank you.

maxkatz6 commented 4 years ago

Just for case, if you need to render simple html without css/js and else, you can use Avalonia.HtmlRenderer https://github.com/AvaloniaUI/Avalonia.HtmlRenderer/pull/7

wuzlai commented 4 years ago

Just for case, if you need to render simple html without css/js and else, you can use Avalonia.HtmlRenderer AvaloniaUI/Avalonia.HtmlRenderer#7

Hi,man.maybe your suggestion can be a new way , can you give mes some demo or guide for Avalonia.HtmlRenderer. i do not konw how to use Avalonia.HtmlRenderer.although i have read the AvaloniaUI/Avalonia.HtmlRenderer#7.

spchamp commented 3 years ago

For HTML display in a sense like of a WebView control with Avalonia, there is a WebViewControl-Avalonia available (NuGet) (GitHub) (SampleWebView.Avalonia). There's also a WebViewControl-Avalonia-RemoteDebugSupport (NuGet) from the same project. The NuGet package targets .NETStandard 2.0.

It uses CefGlue (NuGet) (developer's fork).

sunsided commented 2 years ago

Just to add to @spchamp's answer: From what I just learned, WebViewControl-Avalonia will currently not work on Linux. According to https://github.com/OutSystems/CefGlue/issues/18#issuecomment-917942591 (September '21):

Linux support is not in the near future plans.

erichiller commented 2 years ago

Another option (although I haven't tried it yet) is CefNet

maxkatz6 commented 2 years ago

There are different solutions for this problem. Probably the most popular - to bundle CEF engine with the app using CefGlue or CefNet. Or to use very simple Avalonia.HtmlRenderer with limited rendering capabilities. Or to use native web views (Edge, Safari...) via NativeControlHost like here https://github.com/maxkatz6/AvaloniaWebView