I can't get interactive mudblazor components to work on interactive pages in .net 8 after creating a new project with the .net 8 template. Not sure what I am doing wrong. I have a .net 7 project that I would like to upgrade but I am not even going to try until I get this working. I have tried a lot of Blazor component libraries, but I like MB the best and really want this to work.
I tried InteractiveServer, InteractiveAuto, and InteractiveWebAssembly. I tried various includes of blazor components (VS 2022 said I didn't need them). I specifically tested dialog and menu.
OK! so with mudblazor components in .net 8.0 you can not run the application in some of the rendering options added to .net 8.0.
For most of your components like buttons and dialogs you need to add the fallowing to your MainLayout.razor file
<MudThemeProvider @rendermode="InteractiveServer" />
<MudSnackbarProvider @rendermode="InteractiveServer" />
<MudDialogProvider @rendermode="InteractiveServer" />
And set up javascript for mudblazor by adding the fallowing line to the body section of app.razor:
<script src="_content/MudBlazor/MudBlazor.min.js"></script>
I did not remove:
<script src="_framework/blazor.web.js"></script>
and dont forget to set up your components in program.cs and your using statements in _imports.razor IE:
builder.Services.AddMudServices();
This page is the ONLY page I have found that helps with my issues, so feel free to look into this as well as anything I have personally done to get functionality to work is here https://github.com/MudBlazor/MudBlazor/issues/7774
I'm currently still working on getting themes to work as that appears to break my functionality as soon as I add a customTheme class, but I'm not 100% about that, maybe something in my actual custom theme is breaking it.
Given a re-read I think this is only relevant to starting a default razor .net 8.0 project and adding mud. My apologies but ill leave it up just in case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With