0
我嘗試獲取單元格內容作爲類,例如我綁定 我該怎麼做?DataGridCell獲取綁定值
<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;
}
}
我不明白你正在嘗試做的(你的問題不清楚),你找'值TextBlcock'? – Sayse 2014-08-28 13:44:21
我綁定一個DataTable它包含一個Colums到網格,如 dcolumn = new DataColumn(「colname」); dcolumn.Caption =「colname Caption」; dcolumn.DataType = typeof(MyClass); this.Data.Columns.Add(dcolumn); 我嘗試在轉換器中獲取MyClass數據 – 2014-08-28 13:54:05