A .NET library that embeds Chromium (CEF) into Avalonia as a reusable control and demo.
DNCefView.Avalonia provides a CefView control for rendering web content inside Avalonia applications and handling typical browser interactions such as input, focus, JavaScript dialogs, rendering callbacks, and more.
Key points
- Project: DNCefView.Avalonia
- Demo: DNCefView.Avalonia.Demo
- Target framework: .NET 8
Features
- Embedded Chromium rendering via CEF
- Integration with Avalonia's event loop and input system
- Support for context menus, cursor handling, IME, JS dialogs, and other browser features
- A demo application for quick verification and development
Prerequisites
- .NET 8 SDK (verify with
dotnet --version, should report 8.x) - Platform-specific native dependencies for CEF may be required. On Windows, ensure any required native runtimes or binaries are available to the demo or consuming application.
Quickstart (build and run the demo from source)
- Open the repository root (contains
DNCefView.Avalonia.slnx). - Build the solution:
dotnet build DNCefView.Avalonia.slnx -c Debug- Run the demo app:
cd DNCefView.Avalonia.Demo
dotnet runThe demo (DNCefView.Avalonia.Demo) launches an Avalonia window and loads the sample pages under webres/ (for example, webres/index.html or webres/iframe.html) to demonstrate CefView behavior.
Using CefView in your Avalonia app
- Reference the
DNCefView.Avaloniaproject or its package in your application. - Add the
CefViewcontrol in XAML or code (see the demo for examples).
Example (conceptual):
<!-- Place the control in an Avalonia window -->
<local:CefView Width="800" Height="600" />For API details and available events, see CefView.cs and the related partial files such as CefView+Render.cs and CefView+Input.cs in the repository.
Development and debugging tips
- If you encounter native dependency or runtime errors, inspect the demo's console output and the
obj/andbin/folders for generated runtime assets and missing native libraries. - CEF native binaries and runtime requirements differ across Windows, macOS, and Linux. Provide the appropriate native files for the target platform when running the demo or packaging your app.
Contributing
- Contributions are welcome. Please open issues or submit pull requests with reproducible steps and test instructions.
Acknowlegements
- This project builds on CEF and Avalonia—many thanks to those open-source communities.
If you want this README translated into another language, extended with a detailed API reference, or augmented with a minimal runnable example, tell me which you prefer and I will update the file.