I'm learning blazor and am working on a relatively simple blazor app with MudBlazor and .NET 8. I'm at a bit of a loss as to why this isn't working. I want to open a simple dialog, and just as the example in the documentation suggests, I've added <MudDialogProvider /> to my MainLayout.razor and defined the dialog as follows:
Test.razor
@inject IDialogService DialogService@rendermode InteractiveServer<h3>Test</h3><MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@Add">Add</MudButton>@code { private void Add() { var options = new DialogOptions { CloseOnEscapeKey = true }; DialogService.Show<TestDialog>("Test", options); }}TestDialog.razor
<MudDialog><DialogContent> Dialog Test</DialogContent><DialogActions><MudButton Color="Color.Primary" OnClick="Submit">Ok</MudButton></DialogActions></MudDialog>@code { [CascadingParameter] MudDialogInstance MudDialog { get; set; } void Submit() => MudDialog.Close(DialogResult.Ok(true));}MainLayout.razor
@inherits LayoutComponentBase<MudThemeProvider /><MudDialogProvider /><MudSnackbarProvider /><MudLayout><MudAppBar><MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Inherit" Edge="Edge.Start" OnClick="@((e) => DrawerToggle())" /> My Application</MudAppBar><MudDrawer @bind-Open="@_drawerOpen"><NavMenu /></MudDrawer><MudMainContent> @Body</MudMainContent></MudLayout>@code { bool _drawerOpen = true; void DrawerToggle() { _drawerOpen = !_drawerOpen; }}When pressing the view button, nothing happens and no error is throw. I've also tried adding @rendermode InteractiveServer to TestDialog.razor but that didn't change anything either. When debugging, it reaches DialogService.Show with now issue and does not throw an error. For most other people with this issue it seems to be the missing <MudDialogProvider /> that solves it but I have already had that added.
If I try to add @rendermode InteractiveServer to MainLayout.razor, I get the following error:
InvalidOperationException: Cannot pass the parameter 'Body' to component 'MainLayout' with rendermode 'InteractiveServerRenderMode'. This is because the parameter is of the delegate type 'Microsoft.AspNetCore.Components.RenderFragment', which is arbitrary code and cannot be serializedThis post suggested adding the render mode to App.razor instead, which works fine but doesn't help with the dialog issue either.
My app is currently set up to run just with the Interactive Servcer render mode. Is there something really obvious here I am overlooking?