给定包含已关闭组的Silverlight 3数据网格,当通过单击列标题启动行排序时,所有已关闭的组都将打开以显示其内容。有什么办法可以阻止这一切发生吗?
我在2009年7月的工具包中使用Silverlight3。
我为datagrid编写了一个扩展方法:
public static void CollapseAllGroups(this DataGrid dataGrid) { dataGrid.Dispatcher.BeginInvoke(delegate { var cv = dataGrid.ItemsSource as ICollectionView; if (cv != null && cv.Groups != null) { foreach (CollectionViewGroup groupname in cv.Groups) { dataGrid.CollapseRowGroup(groupname, true); } } }); }
在我的例子中,我将它挂接到底层domaindatasource的dataloaded事件上。