Skip to content

Cross-platform web view for Avalonia but with standardized dependency injection

License

Notifications You must be signed in to change notification settings

acard0/Avalonia.WebView

 
 

Repository files navigation

Avalonia.WebView

WebView for avalonia

sample usage

 var services = new ServiceCollection()
 .AddDesktopWebViewServices(false)
 .AddAvaloniaBlazorWebViewServices(
     new WebViewCreationProperties(),
     config =>
     {
         config.ComponentType = typeof(SampleBlazorWebViewShared.AppWeb);
         config.Selector = "#app";
         config.ResourceAssembly = typeof(SampleBlazorWebViewShared.AppWeb).Assembly;
         config.AppAddress = "0.0.0.0";
     }
 )
 .AddGlobalForServer();

 services.Add(ServiceDescriptor.Singleton(typeof(ILoggerFactory), _loggerFactory));
 services.Add(ServiceDescriptor.Singleton(typeof(ILogger<>), typeof(Logger<>)));

 services
 .AddMasaBlazor(builder =>
 {
     builder.ConfigureTheme(theme =>
     {
         theme.Themes.Light.Primary = "#4318FF";
         theme.Themes.Light.Accent = "#4318FF";
     });
 }).AddI18nForServer("wwwroot/i18n");

 var provider = services.BuildServiceProvider();

 _logger.LogInformation("Setting up BlazorWebView");

 var webView = new BlazorWebView(provider);
 webView.HostPage = @"wwwroot/index.html";
 webView.RootComponents.Add<HeadOutlet>("head::after");
 webView.WebViewCreated += WebView_WebViewCreated;

 Content = webView;

Credits

Full credit goes to https://github.com/MicroSugarDeveloperOrg

Avalonia

Maui

Xamarin.MacIos

Microsoft.WebView2

GTKSharp

WebkitGtkSharp

About

Cross-platform web view for Avalonia but with standardized dependency injection

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 99.0%
  • Other 1.0%