Install

Just download the DLL and reference it in your project. In order to work properly you also need to provide the WPFToolkit.dll, either installed on your computer or in the local folder where your application executes.

Usage

Currently the library contains two formatters you can choose from: DataGridConditionalRowFormatter and DataGridConditionalCellFormatter. If you want conditional fromatting on a given grid just create an instance of one of the provided formatters and pass the appropriate parameters to it. The style will be applied automatically at runtime.

Here's an example on how to format a grid row based on a cell value:

Let's first assume we have a list of products. Each product is defined as follows:
public class Product
{
public string Name { get; set; }
public decimal Price { get; set; }
public double OrderNumber { get; set; }
}

The list with products is bound to a datagrid. You may then assign conditional fromatting as follows:
new DataGridConditionalRowFormatter(this.dataGrid, "Price", NumericOperator.GreaterThan, "10")
{
ConditionalBackgroundColor = Colors.OrangeRed,
ConditionalTextColor = Colors.White,
NormalBackgroundColor = Colors.LightGreen
};

This will create a row formatter which applies a color of orange red to all rows whose price is greater than ten.

Conditional row formatting

Last edited May 17, 2011 at 2:50 PM by DaniGee, version 2

Comments

No comments yet.