Hi,
I went through all the documentation on Datagrid columns, but still, can't figure out is there a possibility to make a column that has an icon before the text, I'm trying to do something like this:
Also, I've found a very similar question with an answer, but unfortunately for me, it was for WinForms not for the WPF solution.
https://www.syncfusion.com/forums/153880/solved-how-to-add-custom-column-icon-and-text-on-datagrid
|
<syncfusion:GridTemplateColumn MappingName="Trustworthiness" HeaderText="Trustworthiness">
<syncfusion:GridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid Margin="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="15"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Image Source="{Binding Trustworthiness,
Converter={StaticResource trustImageConverter}}"
Height="15" Width="15" Grid.Column="0"/>
<TextBlock Text="{Binding Trustworthiness}" Padding="4"
VerticalAlignment="Center" Grid.Column="1"/>
</Grid>
</DataTemplate>
</syncfusion:GridTemplateColumn.CellTemplate>
<syncfusion:GridTemplateColumn.EditTemplate>
<DataTemplate>
<TextBox Text="{Binding Trustworthiness}" Padding="4"
VerticalAlignment="Center" Grid.Column="1"/>
</DataTemplate>
</syncfusion:GridTemplateColumn.EditTemplate>
</syncfusion:GridTemplateColumn> |
|
internal class TrustImageConverter : IValueConverter
{
object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo info)
{
if (value == null || string.IsNullOrEmpty(value.ToString()))
return null;
else
return @"Images/"+ value.ToString()+".png";
}
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo info)
{
throw new NotImplementedException();
}
} |
Thank you, for the solution, this helped me =)