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.
- Android implementation to dynamically change the color of graphics in shapexml
- dart - i want to change the border color when selected with flutter's filter chip
- i would like to know how to change the lock screen image of windows 10 with c #
- java - i want to dynamically change the excel file name generated by servlet
- c # - change the output destination of entered text
- c # - setting defaultprintqueue in localprintserver does not change default printer settings
- html - [beginner] i can't change the background color of the header
- i want to change the text color from black to purple when clicking with jquery
- c # - i want to change the landing prediction circle of thrown objects etc with unity depending on the terrain
- html - how to change the color of in tag when hovering
- c # - i want to create a panel dynamically and write the process when the panel is clicked
- how to make a boxplot of data containing nan in matplotlib and change the color
- python - i want to change the text color of the pandasplot label
- css3 - i want to change the color of the fontawesome link on the page where googleform is embedded
- c # - i want to change the viewpoint of the camera when i press the "1" key
- c # - change the size of the panel according to the size of the window
- Android implements to change the color of a part of the bitmap image to other colors
- c # - wpf i want to display the datagrid with the specified column of the acquired csv
- c # - [mvvm] [prism] the image is not updated even when the bound bitmapimage is updated
- c # - i want to change the font of textblock with fontdialog
- c # - wpf | two windows start up at startup
- access is denied when c #: streamwriter is executed also, what you want to do
- c # - i want to create a hover action using a gradient in wpf
- c # - i want to enable/disable the "x" button at the top right of the xaml window
- [c #] i want to operate image controls collectively in wpf
- c # - specify layout of touch keyboard on wpf app
- c # - if there is no code behind, can i delete ~ xamlcs?