Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4055

Use ref of inherited component in .NET Blazor

$
0
0

How can I access the MudMenu ref properties when using the Menu component? If I use the Menu _menuRef, then I don't have access to MudMenu properties. If I use MudMenu _menuRef, then I get access to the properties but instead get an error saying it can't convert MudMenu to Menu.

Are there any workarounds for this? Can I set Menu.razor to always be of type MudMenu? Or can I expose the properties manually somehow?

Menu.razor:

@inherits MudMenu@{    base.BuildRenderTree(__builder);}@code {    protected override void OnInitialized()    {        base.OnInitialized();        PopoverClass = "mt-1";        Dense = true;    }}

Using component:

<Menu @ref="@_menuRef">@code {    MudMenu _menuRef;    async Task Test()    {        await _menuRef.CloseMenuAsync();    }}

Viewing all articles
Browse latest Browse all 4055

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>