What are MudBlazor API Methods for and how do you access them?

Viewed 108

MudBlazor documents various "API Methods" for each of its components, but it is unclear when or how you are intended to make use of these methods. For example, MudMenu has a "Close()" method. I'd love to be able to call that in response to certain user actions, to forcibly remove a popped-up menu, but I cannot see any way to make use of it.

Can anyone explain when and how you are intended to use these methods? They seem to be carefully documented, so I'm assuming we are supposed to make use of them somehow!

1 Answers

To use CloseMenu() Methode you have to create a reference

add the @ref

<MudMenu @ref="Menu" Label="Default Menu Width" Variant="Variant.Filled" Color="Color.Primary">
    .

</MudMenu>

and in the c# code

private MudMenu Menu{get;set;}

private void Close(){
    Menu.CloseMenu();
}
Related