MobileBlazorBindings
MobileBlazorBindings copied to clipboard
Reusable blazor components
I have a web application in blazor wasm, I would like to reuse blazor wasm login and registration in my xamarin application, is there a way to use my 2 blazor components in xamarin?
my xamarin app is not blazor bindings.
@angelru yes, in general you should be able to add a BlazorWebView control from Mobile Blazor Bindings to your Xamarin.Forms app, and you can then host your Blazor web components in that BlazorWebView.
@Eilon I have several doubts, my xamarin forms project is not from Mobile Blazor Bindings, I would have to install the nuget package and then the configurations no? then what I do not see clear is to put only my 2 components that I want to reuse, since I do not want the complete application.
Hi @angelru it's probably simpler than you might think 😄 A Mobile Blazor Bindings app is really a Xamarin.Forms app that happens to use a BlazorWebView control that loads some Blazor. There are a few extra project settings in a few places. We have minimal docs on this topic right now, but in general, the process is to create a new empty Blazor Hybrid app, look at the various settings and contents of the project, and copy it to your existing Xamarin.Forms app.
@Eilon Thank you very much, I'll see what I can do ...
so it's basically adding a browser in your xamarin app? My blazor component can't communicate with the others c# codes in my xamarin because they are running in a sandox inside a browser?
@Xyncgas that isn't the case. All the C# code in a Mobile Blazor Bindings app runs in the same process and can all "talk" to each other. There's no browser sandbox for the C# code, and there's no Web Assembly. The browser is only used to render the HTML, and optionally run any custom JS that you might have (e.g. 3rd party component such a Bootstrap, or your own custom JS code).
@Xyncgas that isn't the case. All the C# code in a Mobile Blazor Bindings app runs in the same process and can all "talk" to each other. There's no browser sandbox for the C# code, and there's no Web Assembly. The browser is only used to render the HTML, and optionally run any custom JS that you might have (e.g. 3rd party component such a Bootstrap, or your own custom JS code).
Ohh, so people found a way to let the MBB App talk to the browser and tell it what to render, while MBBA itself not running in the browser? that's so cool !!! what kind of magic is this
@Xyncgas both Mobile Blazor Bindings (experimental) and Blazor Desktop (supported) use the same technique to run the app. All the .NET code runs in the same process, it's just that the Blazor code renders the HTML into a WebView control for the UI to show up. No C#/.NET code runs "in" the WebView control (so there's no Web Assembly here, and also no SignalR). I talk about this a bit on this video I recently made: https://www.youtube.com/watch?v=oNxUfPoAXac
Is there a new way or is what you told me in this thread the correct way? or do we have to wait for MAUI?
@angelru the way this works is the same between Mobile Blazor Bindings and .NET MAUI w/ BlazorWebView. You can place your various Blazor components in a Razor Class Library (RCL) and then reference them from Blazor WebAssembly, Blazor Server, or Blazor Desktop (in .NET MAUI, WinForms, or WPF).