本例是将DataTable中的数据显示到DataGrid中。用List绑定的原理差不多。 XAML
<DataGridTemplateColumn Width="80" Header="颜色">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Name="ColorLabel" Background="{Binding Color}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
后台
DataTable DT1 = new System.Data.DataTable();
DT1.Columns.Add("Color", typeof(string));
DataRow row = DT1.NewRow();
row["Color"]="#111111";