79382168

Date: 2025-01-23 18:27:18
Score: 0.5
Natty:
Report link

Just @bind your ActivePanelIndex to a property instead of a field, and do more code in the set property:

<MudTabs Elevation="0" Outlined="true" @bind-ActivePanelIndex="ActiveIndex">
   <MudTabPanel Text="Red"></MudTabPanel>
   <MudTabPanel Text="Blue"></MudTabPanel>
</MudTabs>

<MyBox colorBox="@_colorMe" />

@code
{
   string _colorMe = "red"; 

   private int _activeIndex;
   
   private int ActiveIndex { 
     get => _activeIndex;
     set {
       _activeIndex = value;
       _colorMe = new[]{"red","blue"}[_activeIndex];    //or run a method etc
     }
  }
}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @bind
  • Low reputation (0.5):
Posted by: flackoverstow