我有这样的数据网格填充:
DataTable tableBig = new DataTable();
public MainWindow() {
PO3.DataContext = tableBig;
tableBig.Columns.Add("test", typeof(SomeClass));
tableBig.Rows.Add(new SomeClass());
}
这是我的xaml:
<DataGrid Name="PO3" HorizontalAlignment="Left" Margin="323,281,0,0" VerticalAlignment="Top" ItemsSource="{Binding}" Height="134" Width="340">
这是一个类:
public class SomeClass {
public static readonly DependencyProperty TagProperty = DependencyProperty.RegisterAttached(
"Tag",
typeof(object),
typeof(SomeClass),
new FrameworkPropertyMetadata(null));
int intt = 0;
public static object GetTag(DependencyObject dependencyObject) {
return dependencyObject.GetValue(TagProperty);
}
public static void SetTag(DependencyObject dependencyObject, object value) {
dependencyObject.SetValue(TagProperty, value);
}
}
可以根据标签属性更改datagridcell内的颜色吗? 也许有一个触发器,但我不知道。