0
DataGridCell設定值我有這樣的DataGridCell和它調用該轉換器。我期待這個單元格的值是「嗨」(因爲我將單元格的內容設置爲「嗨」),當它通過轉換器後顯示在數據網格中。C#WPF從轉換器
我在這裏做錯了什麼?
<DataGridTextColumn Width="60" Header="Google" CanUserResize="True" CanUserSort="True">
<DataGridTextColumn.HeaderStyle>
<Style TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="ToolTip" Value="Current Position on Google" />
<Setter Property="HorizontalContentAlignment" Value="Center"/>
</Style>
</DataGridTextColumn.HeaderStyle>
<DataGridTextColumn.CellStyle>
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="FontSize" Value="12"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<EventSetter Event="MouseUp" Handler="IdUnselect"/>
<Setter Property="Background" Value="{Binding GoogleKeywordPositionMovementSinceLastWeekCheck, Converter={StaticResource NameToBrushConverter}}"/>
<Setter Property="Content" Value="{Binding Path=., Converter={StaticResource GooglePositionConvertor}}"/>
</Style>
</DataGridTextColumn.CellStyle>
</DataGridTextColumn>
public class GooglePositionConvertor : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
ResultCheckObject RankCheck = value as ResultCheckObject;
return "hi";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
綁定到當前的源路徑=,但什麼是你的電流源!?並在轉換器中將值轉換爲ResultCheckObject,但只返回「嗨」,那麼爲什麼要在不使用它的情況下轉換該值? –
如何通過轉換器設置datagrid單元格的內容/文本? – jamie
例如,你可以有一些財產INT數據CONTEX綁定到,則該屬性值將通過轉換器,並返回 –