0

I am displaying a poor to excellent rating and id like to color code each. I can't figure out how to use the color #203b86. I also have this in my code displaying the colors on a grid object somewhere different.

public IEnumerable<string> colors = new string[] { "#203b86", "#7cc40a", "#009ade", "#ff5f00", "#00d8d2" };

This is the color scheme being used.

<RadzenLabel> 
  Poor @SurveyResults.Where(x =\> x.GetType().GetProperty(property).GetValue(x).ToString() == "Poor").Count() @colors="#203b86".ToString()
</RadzenLabel>

This is my code but its displaying @colors="#203b86".ToString(). I only want the color.

Flydog57
  • 6,851
  • 2
  • 17
  • 18

1 Answers1

0

You have to add a style property and give it a string where you define the colors etc.

I would recommend you to separate it in a class file or at the end of the blazor file to the @code-area, because it will be much more readable.

<RadzenLabel Style="@ExampleStyle" Text="ExampleText" />
<RadzenDropDown @bind-Value=@SelectedItem Data=@SelectableItems Change="OnSelectionChanged" />

@code
{
    public string ExampleStyle;
    public IEnumerable<string> SelectableItems;
    public string SelectedItem;

    protected override void OnInitialized()
    {
        SelectableItems = new string[] { "Good", "Bad" };
        SelectedItem = SelectableItems.FirstOrDefault();
        OnSelectionChanged();
    }

    public void OnSelectionChanged()
    {
        if (SelectedItem == "Good")
            ExampleStyle = "background-color: #000000; color: #ffffff";
        else
            ExampleStyle = "background-color: #ffffff; color: #000000;";
    }
}

Result of the example

Kevin D.
  • 1
  • 3