Not limited to text color, but generally when I want to draw a screen with dynamically changing values ​​in XAML
What processing is appropriate to write?

Taking the above text color as an example
1. Bind a Foreground value (such as Red) as a string from a ViewModel property
→ If this is the case, the screen (character color) will be described in the ViewModel, so isn't it all right?

2. Write a DataTrigger that sets the value of Foreground to △△ if the value passed from ViewModel to XAML is ○○
→ Is it better to do this because anything related to screen drawing can be described on the View side?

Only the above two points are understood, which is appropriate?
If i have a more appropriate description method, can you teach me?

Thanks for your consideration.

  • Answer # 1

    I think it depends on what you want to change the color for, but if you want to represent the data visually, the second way is good.

    If it is just a matter of appearance regardless of the data to be handled, it is better to create a property that holds color information in an object that holds application settings (usually Properties.Settings.Default) and bind it to it.

Related articles