简体   繁体   English

Blazor 中的隐藏/显示菜单名称

[英]HIDE /SHOW Menu Names in Blazor

I am New to Blazor UI development I have been trying to work on this menu to initially look like in this picture我是 Blazor UI 开发的新手 我一直在尝试在此菜单上工作,最初看起来像这张图片

按钮事件之前

after a button click on the top of the menu it should look like the below picture单击菜单顶部的按钮后,它应该如下图所示单击菜单顶部的按钮后,它应该如下图所示

the code I tried was hiding the menu with icons too, Kindly Help me out here.我尝试的代码也隐藏了带有图标的菜单,请在这里帮助我。 Thanks谢谢

I would recommend you to use another library (extension) on top of Blazor.我建议您在 Blazor 之上使用另一个库(扩展)。 A very handy and proven (free to use) library is, for example, MudBlazor.例如,MudBlazor 是一个非常方便且经过验证(免费使用)的库。 You can find the documentation here: https://mudblazor.com/您可以在此处找到文档: https://mudblazor.com/

What you describe can be achieved using this library, for example with the following code:您所描述的可以使用这个库来实现,例如使用以下代码:

<MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Inherit" Edge="Edge.Start" OnClick="@ToggleDrawer" />

<MudDrawer @bind-Open="@open" Variant="@DrawerVariant.Mini">
    <MudNavMenu >
        <MudNavLink Icon="@Icons.Filled.Calculate">Link1</MudNavLink>
        <MudNavLink Icon="@Icons.Filled.LocalCafe">Link2</MudNavLink>
    </MudNavMenu>
</MudDrawer>

@code {
    private bool open = true;

    private void ToggleDrawer()
    {
        open = !open;
    }
}

You can try this code here: https://try.mudblazor.com/snippet/QaQmYZEsxBSUEJuv您可以在此处尝试此代码: https://try.mudblazor.com/snippet/QaQmYZEsxBSUEJuv

I dont know will it work for you but u can try something like making 2 panel one is for logos and other is for texts.我不知道它对你有用,但你可以尝试制作 2 个面板,一个用于徽标,另一个用于文本。 Then just write panel2.visible = false in form load.然后只需在表单加载中写入panel2.visible = false After that write inside that showing texts button.之后在显示文本按钮内写入。

if(panel2.visibile == false)
{
panel2.visible = true
}
else if (panel2.visibile == true)
{
panel2.visible = false
}

I dont know is this what u want but u can try it just 3 lines of code我不知道这是你想要的,但你可以试试 3 行代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM