c# – Silverlight:在DataGridRowGroupHeader事件中获取RowGroupHeader值
作者:互联网
我正在将datagrid分组到一个子级别.
像这样:
CollectionViewSource pageView = new CollectionViewSource();
pageView.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
pageView.GroupDescriptions.Add(new PropertyGroupDescription("SubCategory"));
tasksDataGrid.ItemsSource = pageView.View;
在我的情况下,一些记录没有Subcategory值.这些记录将显示在datagrid中Subcategory的空行组标题下.
我想直接显示在类别行组标题下而不是空标题下.
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;
}
}
我无法获取当前加载的RowGroupHeader值.如何在LoadingRowGroup事件中获取RowGroupHeader值.
帮助我.
解决方法:
这解决了这个问题.
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;
}
}
感谢djohnsonm的帮助.
标签:c,xaml,silverlight,silverlight-4-0 来源: https://codeday.me/bug/20190710/1418800.html