2009-10-18 19 views
1

给定一个包含关闭组的Silverlight 3数据网格,当通过单击列标题启动行排序时,将打开所有关闭组以显示其内容。有什么办法可以阻止这种情况发生?Silverlight数据网格分组/排序行为

我在2009年7月的工具包中使用了Silverlight 3。

回答

1

我写的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); 
       } 
      } 
     }); 
    } 

在我来说,我把它勾到底层Dom​​ainDataSource的DataLoaded事件。