c# – Silverlight:在DataGridRowGroupHeader事件中获取RowGrou
发布时间:2020-12-15 21:21:43 所属栏目:百科 来源:网络整理
导读:我正在将datagrid分组到一个子级别. 像这样: CollectionViewSource pageView = new CollectionViewSource(); pageView.GroupDescriptions.Add(new PropertyGroupDescription("Category")); pageView.GroupDescriptions.Add(new PropertyGroupDescription("S
我正在将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的帮助. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |