How to use Bootstrap modal in Blazor client app?

There is likely a better way to do this, but here’s a working example to get you started: Page: @page “/modal-test” <BlazorApp1.Components.Modal @ref=”Modal”></BlazorApp1.Components.Modal> <button @onclick=”() => Modal.Open()”>Open Modal</button> @code { private BlazorApp1.Components.Modal Modal { get; set; } } Component: <div class=”modal @ModalClass” tabindex=”-1″ role=”dialog” style=”display:@ModalDisplay”> <div class=”modal-dialog” role=”document”> <div class=”modal-content”> <div class=”modal-header”> <h5 class=”modal-title”>Modal title</h5> … Read more

Embedding a Leaflet map on a Blazor SPA

Note: The sample code below was created and tested in a WebAssembly Blazor App stand alone… An object reference is required for the nonstatic field, method, or property ‘member’ Let’s create the object class, whose object reference will be passed to your JavaScript’s object when initialized. When the user clicks on a location on the … Read more

Best way to share data between two child components in Blazor

You may define a class service that implements the State pattern and the Notifier pattern to handle the state of your objects, pass state to objects, and notify subscriber objects of changes. Here’s a simplified example of such service, which enables a parent component to communicate with his children. NotifierService.cs public class NotifierService { private … Read more