Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
XamDataGrid conditional format background color with multiple colors


based on the example conditional format I tried to put a LinearGradientBrush as background into the cell of the XamDatagrid. Each employee has one row and every day is one column.

The differences are:

1. I would like to use multiple colors:

a) grey if the day is non working day (weekend, holidays)

b) complete red if there is no working assignment at all

c) blue if the employee is on vacation

d) draw a section of the cell in green and the rest in red if the employee is assigned only for a fraction of his time (e.g. total working time 8h, he is assigned only 3 of them to a project)

2. I am not using a converter but put a property on the object that is in a List<T> which is bound to the XamDatagrid.

I get close to the desired result but the LinearGradientBrush creates (of course) gradients while I am looking for sharp seperation of colors. The whole thing is actually a small stacked bar diagramm in a cell.

Is there a way to achieve this?



No Data
  • 18204
    Verified Answer
    Offline posted

    Hello Niko,

    Thank you for contacting Infragistics Developer Support.

    I understand that you are trying to display a sharp gradient in the XamDataGrid's cells.

    I am not sure I completely understand how your List<T> data looks like, but you can add a more sharp gradient by adding an extra stop using the next color you want.

    The below example code will draw Red and Green interpolating evenly in the first half, and a sharper Blue in the right half.

    <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
                <GradientStop Offset="0"      Color="#FFff0000"/>
                <GradientStop Offset="0.5"    Color="#FF00ff00"/>
                <GradientStop Offset="0.5001" Color="#FF0000ff"/>
                <GradientStop Offset="1"      Color="#FF0000ff"/>

    Let me know if I may be of further assistance.

    Michael H.
    Software Developer
    Infragistics, Inc.

No Data