我尝试将单元格内容作为一个类获取,例如我绑定我该怎么做?
<Style TargetType="{x:Type DataGridCell}">
<Style.Triggers >
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Content, Converter={StaticResource MyConverter}}" Value="1">
<Setter Property="Margin" Value="15,0,0,0" />
</DataTrigger>
</Style.Triggers>
</Style>
这是转换器类:
public class MyConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value!= null)
{
//to do value is TextBlcock and I cant get value need I
}
return value;
}
}