Silverlight: get RowGroupHeader value in the DataGridRowGroupHeader event

I group a datagrid to one sublevel.

Like this:

CollectionViewSource pageView = new CollectionViewSource(); pageView.GroupDescriptions.Add(new PropertyGroupDescription("Category")); pageView.GroupDescriptions.Add(new PropertyGroupDescription("SubCategory")); tasksDataGrid.ItemsSource = pageView.View; 

In my case, some entries do not have a subcategory value. These records will be displayed under the heading of the empty row group subcategory in the datagrid.

I would like to display directly below the heading of a group of rows, rather than an empty heading.

  private void TaskDataGrid_LoadingRowGroup(object sender, DataGridRowGroupHeaderEventArgs e) { string RowGroupHeader = // how to get currently loading header value if(RowGroupHeader == string.Empty) { e.RowGroupHeader.Height = 0; } } 

Currently, I cannot load the value of RowGroupHeader. How can I get the value of RowGroupHeader in the LoadingRowGroup event.

Help me with this.

+4
source share
2 answers

This solved the problem.

 private void TaskDataGrid_LoadingRowGroup(object sender, DataGridRowGroupHeaderEventArgs e) { var RowGroupHeader = (e.RowGroupHeader.DataContext as CollectionViewGroup); if (RowGroupHeader != null && RowGroupHeader.Items.Count != 0) { MasterTask task = RowGroupHeader.Items[0] as MasterTask; if (task != null && task.SubCategoryName == null) e.RowGroupHeader.Height = 0; } } 

Thanks djohnsonm for your help.

+1
source

Try this, but insert the name of your virtual machine and the property that matches the value of the header.

 private void TaskDataGrid_LoadingRowGroup(object sender, DataGridRowGroupHeaderEventArgs e) { string RowGroupHeader = (e.RowGroupHeader.DataContext as ParentVM).VMProperty if(RowGroupHeader == string.Empty) { e.RowGroupHeader.Height = 0; } } 
0
source

All Articles