Creating a reusable UserControl that wraps a JavaScript UI library #20522
rbrundritt
started this conversation in
General
Replies: 1 comment 2 replies
-
This one is actually the easiest. Avalonia supports "native" interop. Native for a web browser is HTML and Javascript. There is a sample here for embedding some HTML in an Avalonia control for web assembly and calling some Javascript code. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm looking to create a reusable user control that wraps a JavaScript UI library, in particular MapLibre (similar to Leaflet/Google Maps) as I need this for larger project I'm working on. My ultimate goal is to create a .NET API interface that wraps a chunk of this JavaScript library and is able to run this in offline scenarios. This would require hosting the JavaScript files for the library with the user control, as well as having some data offline for rendering.
I have created a very similar project previously for .NET Maui for Azure Maps (https://github.com/rbrundritt/AzureMapsNativeControl). In that solution I wrapped the .NET Maui Hybrid WebView control (https://github.com/[Eilon/MauiHybridWebView](https://github.com/Eilon/MauiHybridWebView)), made all my HTML/JS files embedded resources in my project, and loaded and controlled them within the WebView. I create an API interface similar to that of the library I was wrapping and create JS interop code as needed.
The above solution works really well, but now I'm working with a customer who needs a solution for Avalonia that works across all flavors (mobile, desktop, and Web Assembly). Before I go too far down the rabbit hole I'm looking for some insights, in particular:
Note: I am aware of MapsUI and have tested it. It does not have the features of performance level I require.
Beta Was this translation helpful? Give feedback.
All reactions