Search code examples
c#visual-studioblazormudblazor

Hiding MudText dynamically in blazor


I am using Mudtext binded to a property:

<MudTextField Value="@MyClass.Age" Label="Age"  />

I can't find way to hide this textbox dynamically based on some property.


Solution

  • Usually if you don't want to display something based on a value of a variable you use in your Razor page:

    @if(shown)
    {
        <MudTextField Value="@MyClass.Age" Label="Age"  />
    }
    
    @code
    {
       bool shown = true;
       private void SomeFunction()
       {
           shown = false;
       }
    }