

If the response is helpful, please click " Accept Answer" and upvote it.

Here is a simple example with IValueConverter.

Use dependency property to perform calculation based on previous value and this should trigger binding converter where you should set the color. Grid.Background = GetSolidColorBrush("#FFCD3917") The WPF Grid panel does have the concept of a 'cell.' If you want a particular row/column intersection area (aka cell) to have a particular color, put some type of panel in that area and set its Background to that color. Did you tried using ValueConverter for this. SolidColorBrush myBrush = new SolidColorBrush(Windows.UI.Color.FromArgb(a, r, g, b))
#Wpf background color converter update
Update 2 (from the source code): I have found the issue. I want to bind the background color of each item to the Age attribute, I need a Converter. The current Converter is more than enough. to conditionally change rows background color in WPF Edition forum. WPF DataGrid Item background color Binding, Programmer Sought. HEXColor public SolidColorBrush GetSolidColorBrush(string hex)īyte a = (byte)(Convert.ToUInt32(hex.Substring(0, 2), 16)) īyte r = (byte)(Convert.ToUInt32(hex.Substring(2, 2), 16)) īyte g = (byte)(Convert.ToUInt32(hex.Substring(4, 2), 16)) īyte b = (byte)(Convert.ToUInt32(hex.Substring(6, 2), 16)) If I implement the INotifyPropert圜hanged interface, will the value converter I created for setting the background color be called when a value changes or do I need to implement another converter Just implement the INotifyPropert圜hanged interface. Now, change the Blend color picker for the window background from RGB to HLS (by right-clicking on one of the R-G-B-A letters in the color picker) then, drag the L slider to reduce the Luminance value to zero. Grid.Background = new SolidColorBrush(bgcolor) To see the difference, create a new WPF application in Expression Blend and set the window background to this solid color: FFA7BCD7. How i can set color for Background or Foreground in HEX or RGB(ARGB) Ĭolor class contains static FromArgb method, you could use it to create ARGB color then pass it to SolidColorBrush var bgcolor = Color.FromArgb((byte)255, (byte)255, (byte)155, (byte)132)
