cannot set the style property of an element it’s always empty. When I write out StyleString
it says color: red
AT(StyleString = ShouldBeError ? "color: red" : "")
</div>
@StyleString
<MudCard>
<MudCardHeader>
<CardHeaderContent>
<MudText Typo="Typo.h6" Style="AT($"{StyleString}")">
//.....
ATcode {
//...
private bool ShouldBeError;
private string StyleString = "";
private List<Location> Data = new List<Location>();
2
Answers
I put a div above MudText and it worked straight away.
I’m not a MudBlazor user, so here’s a very simple example demonstrating how to set properties on any element/component. In this case the class of the button rather than the style on a component.
[Personal] Note that I try to keep component logic out of the markup whenever I can. I think it’s easier to read.