Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BlazorWebView interaction #417

Open
ghost opened this issue Oct 10, 2021 · 1 comment
Open

BlazorWebView interaction #417

ghost opened this issue Oct 10, 2021 · 1 comment

Comments

@ghost
Copy link

ghost commented Oct 10, 2021

This is not completely related to BlazorMobile bindings, But I created a windows forms app and then render a razor component inside BlazorWebView control:

`BlazorWebView blazorApp = new BlazorWebView()
 {
     Dock = DockStyle.Fill,
     HostPage = "wwwroot/index.html",
     Services = serviceProvider 
 };
 blazorApp.RootComponents.Add<App>("#app");
                
 var form1 = new Form1();
 form1.Controls.Add(blazorApp);
 Application.Run(form1);`

To create a good hybrid app that uses both blazor and win forms, I need to interact between blazor component inside BlazorWebView and Form1, So that I can send data to or call component public methods from Form1 and recieve notifications from the component back to Form1, But I can't find a suitable member in the BlazorWebView's list of members to do this. Is there any way to do this?

@Eilon
Copy link
Member

Eilon commented Oct 12, 2021

@mg1357 , in general the way to do this is so define a "service" in the Dependency Injection (DI) container and then use that service from both the Blazor UI using the @inject directive, and also from the native UI (WinForms/WPF/etc.).

You can learn more about DI here: https://docs.microsoft.com/mobile-blazor-bindings/advanced/dependency-injection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant