* You are viewing the archive for the ‘DataGrid’ Category

Datagrid: support for grouping on columns use IValueConverters to display their value and conditonal rowstyling

DataGrid update

Introduction

Some further enhancements have been made to the DataGrid wrapper that has been the subject of this previous post:

  • Support for grouping on columns that use IValueConverter to display their value
  • Conditional row styling

This post is a code drop for these enhancements.

Conditional row styling

The following code gives a sample on how to use conditional row styling:

public MainPage()
{
InitializeComponent();

theDataGrid.ItemsSource = PersonFactory.GetAllPersons();

theDataGrid.RowStyles.Add(new MyDataGridRowConditionalStyle(
(o) => { return ((Person)o).Name.Contains(“A”); },
Continue Reading

Update postings on Datagrid

Recently I wrote two posts on the Silverlight Datagrid:

Andy noticed that in a comment that the synchronizing of the group row headers with the column headers did not work correctly when the group headers were scrolled out of view and then back into view again.

After investigating the reason of this behavior I have decided to take another approach and to re-implement this functionality. Some additional testing of this new implementation reveals that the issue reported by Andy has been solved. The only quirk … Continue Reading

Drag and Drop grouping in Datagrid

Update

The code for the functionality in this post has been updated in Update postings on Datagrid

Introduction

The DataGrid of the Silverlight Toolkit supports grouping but does not have the ability to drag column headers to the area above the grid to group the data, unlike some other 3rd party datagrids.

This blog presents a solution to implement this functionality. The solution is based upon the solution which can be found on the blog Lee’s corner. … Continue Reading

Synchronizing group row headers with column headers in Silverlight DataGrid

Update

The code for the functionality in this post has been updated in Update postings on Datagrid

Grouping in the DataGrid in Silverlight is quite easy. What is not so obvious is how to change the caption of the column name on the group row. It turns out that you could use the LoadingRowGroup of the DataGrid:

theGrid.LoadingRowGroup += (s, e) =>
{
e.RowGroupHeader.PropertyName = “A custom caption”;
}

The original value of the e.RowGroupHeader.PropertyName is the PropertyName of the PropertyGroupDescription. Using this value the column header can be determined:

private string GetColumnCaption(DataGrid grid, string columnName)
{
Continue Reading