日期:2014-05-20 浏览次数:21196 次
this.datagrid.ItemsSource = table.DefaultView;
<DataGrid HorizontalAlignment="Left" Margin="12,71,0,150" Name="datagrid" Width="853" CanUserAddRows="false" AutoGenerateColumns="True" LayoutUpdated="datagrid_LayoutUpdated" Loaded="datagrid_Loaded" >
<DataGrid.Columns>
<DataGridTemplateColumn Header="选择">
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate />
</DataGridTemplateColumn.CellEditingTemplate>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox Checked="CheckBox_Checked" Tag="{Binding Path= id}" Name="select"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
foreach (var item in datagrid.Items)
{
DataGridTemplateColumn templeColumn = datagrid.Columns[0] as DataGridTemplateColumn;
FrameworkElement s = datagrid.Columns[0].GetCellContent(item);
DataView view = new DataView();
System.Windows.Controls.CheckBox cb = templeColumn.CellTemplate.FindName("select", s) as System.Windows.Controls.CheckBox;