设置单元格的样式
<DataGrid.Columns> <DataGridTextColumn Header="检测项目" Binding="{Binding ItemName}" Width="*" /> <DataGridTemplateColumn Header="详细" Width="80" > <DataGridTemplateColumn.CellTemplate> <DataTemplate> <Button VerticalAlignment="Stretch" Style="{StaticResource NewDialogBtStyleG}" Height="{Binding ElementName=GridTest,Path=RowHeight}" Click="ItemClick" >Button> DataTemplate> DataGridTemplateColumn.CellTemplate> DataGridTemplateColumn>DataGrid.Columns>
效果: