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

How to run a Method by clicking on MudTabPanel in MudBlazor

$
0
0

I want to manipulate with background-color of Component "MyBox" using Tabs. Background of Component has to be filled with the color, named in Tabs.One condition: you're not allowed to delete @bind-ActivePanelIndex="activeIndex" from code (it's used for other purposes).I have a method "SetColor", but I don't understand how to run it.I'll be thankfull for any help.

Index.razor

<MudTabs Elevation="0" Outlined="true" @bind-ActivePanelIndex="activeIndex"><MudTabPanel Text="Red"></MudTabPanel><MudTabPanel Text="Blue"></MudTabPanel></MudTabs><MyBox colorBox="@colorMe"/>@code{    int activeIndex = 0;    string colorMe = "";    void SetColor()    {        if(activeIndex == 0)        {            colorMe = "red";        }         else if(activeIndex == 1)        {            colorMe = "blue";        }     }}

MyBox.razor

<MudItem Style="@($"background-color:{colorBox}; padding:10px; border:1px solid black")">  Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum sit praesentium eos impedit. Est delectus non fugiat perferendis, quos et quis fugit iusto laborum esse voluptates sequi harum quo ab.</MudItem>@code {  [Parameter]  public string colorBox {get; set;}}

Viewing all articles
Browse latest Browse all 4839

Trending Articles



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