C1 DataGrid(silverlight版) 增加合计行
当DataGrid 的AutoGenerateColumns="False" 时,如果增加合计行 c1dg_AutoGeneratingColumn事件只有在自动表头才可以使用 想使用DataGridSummaryRow 回复 3楼roxland的帖子AutoGenerateColumns属性是控制列的。
增加合计行,XAMLcode参考如下:
<c1:C1DataGrid x:Name="grid" AutoGenerateColumns="False" CanUserAddRows="False" CanUserRemoveRows="False" ItemsSource="{Binding Players}" c1:C1NagScreen.Nag="True">
<c1:C1DataGrid.Columns>
<c1:DataGridTextColumn GroupState="Ascending,0" SortState="Ascending,0" SortMemberPath="Name" FilterMemberPath="Name" Width="150" Header="Match" Binding="{Binding Match}">
</c1:DataGridTextColumn>
<c1:DataGridTextColumn Width="150" Header="Goals" Binding="{Binding Goals}">
<c1:DataGridAggregate.AggregateFunctions>
<c1:DataGridAggregatesCollection>
<c1:DataGridAggregateSum />
</c1:DataGridAggregatesCollection>
</c1:DataGridAggregate.AggregateFunctions>
</c1:DataGridTextColumn>
<c1:DataGridTextColumn Width="50" Header="Minutes" Binding="{Binding Minutes}">
<c1:DataGridAggregate.AggregateFunctions>
<c1:DataGridAggregatesCollection>
<c1:DataGridAggregateSum />
</c1:DataGridAggregatesCollection>
</c1:DataGridAggregate.AggregateFunctions>
</c1:DataGridTextColumn>
</c1:C1DataGrid.Columns>
<c1:C1DataGrid.BottomRows>
<c1:DataGridSummaryRow />
<c1:DataGridSummaryRow />
</c1:C1DataGrid.BottomRows>
</c1:C1DataGrid>
需要在LoadedCellPresenter 添加的代码:
If e.Cell.Row.GetType() Is GetType(C1.Silverlight.DataGrid.Summaries.DataGridSummaryRow) Then
Dim _presenter = DirectCast(DirectCast(e.Cell.Presenter.Content, System.Windows.Controls.StackPanel).Children(0), System.Windows.Controls.ContentPresenter)
If (e.Cell.Row.Index = grid.Rows.Count – 2 AndAlso e.Cell.Column.Index = 2) Or (e.Cell.Row.Index = grid.Rows.Count – 1 AndAlso e.Cell.Column.Index = 1) Then
_presenter.Content = String.Empty
End If
End If @Alice,
使用以上方法加合计行,提示:没有:DataGridAggregate.AggregateFunctions这个属性,如何解决? 引用C1.WPF.DataGrid.Summaries,就可以了
@Richard.Ma, 在silverlight里可以这样用吗? @Richard.Ma, 具体怎么引用,麻烦指导一下。 sliverlight 和wpf中的xaml写法是一样的
因为我刚才也拖动了一个datagrid控件到wpf并添加了同样的合计行代码,xaml中也显示了这个错误,如果你遇到的就是这个错误的话,那就是缺少动态库引用导致的
没有的话就会有这个错误
好的,我试一下,谢谢
页:
[1]
2