在WPF DataGrid中分组数据

时间:2018-09-07 06:23:11

标签: c# wpf data-binding wpf-controls wpfdatagrid

我有一个WPF数据网格。我这样将数据绑定到网格。

 <DataGrid Name="DgChips" 
                  Style="{StaticResource DataGridStyle}" 
                  Grid.Row="0" 
                  ColumnHeaderStyle="{StaticResource DataGridColumnHeader}"
                  AutoGenerateColumns="False"
                  xmlns:s="clr-namespace:System;assembly=mscorlib">
            <DataGrid.Resources>
                <s:String x:Key="format">{0:N0}</s:String>
                <s:String x:Key="formatDoller">{0:C0}</s:String>
            </DataGrid.Resources>
            <DataGrid.Columns>
                <DataGridTextColumn 
                    Header="ChipSet Code" 
                    Binding="{Binding sChipSetCode}" 
                    CellStyle="{StaticResource DataGridCellStyleCenter}"
                    />
                <DataGridTextColumn 
                    Header="Denom" 
                    Binding="{Binding iChipDenomination, StringFormat={StaticResource formatDoller}}" 
                    CellStyle="{StaticResource DataGridCellStyleRight}"/>
                <DataGridTextColumn 
                    Header="Count" 
                    Binding="{Binding iChipsCount, StringFormat={StaticResource format}}"  
                    CellStyle="{StaticResource DataGridCellStyleRight}"/>
                <DataGridTextColumn 
                    Header="Value" 
                    Binding="{Binding iChipsValue, StringFormat={StaticResource formatDoller}}"  
                    CellStyle="{StaticResource DataGridCellStyleRight}"/>
            </DataGrid.Columns>
        </DataGrid>

现在,我想对“ sChipSetCode”中的数据进行分组。我该怎么办?

0 个答案:

没有答案