开发者

Silverlight: Get RowGroupHeader value in DataGridRowGroupHeader event

I am grouping datagrid upto one sub-level.

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 records doesn't have Subcategory value.Those records will display under empty row group header of Subcategory in datagrid.

I would like to display directly under Category row group header instead of empty header.

 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;
        }
    }

I can't get currently loading RowGroupHeader value.How can i get RowGroupHeader value in LoadingRowGroup event.

Help me on this.


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.


Try this, but insert the name of your VM and Property that would correspond to the Header value.

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜