BarCode
is a List<T>
and the ToString()
method of List<T>
does not by itself display the contents of the list.
The easiest thing you can do is probably to implement an IValueConverter and apply this converter in your BarCode
binding.
As a start, the converter could look something like this:
public class EanListToStringConverter : IValueConverter {
public object Convert(object value, Type targetType,
object parameter, CultureInfo culture) {
return String.Join(" ", ((List<Ean>)value).Select(ean => ean.Code));
}
public object ConvertBack(object value, Type targetType,
object parameter, CultureInfo culture) {
return NotSupportedException();
}
}
Then, you need to add a converter instance as a resource in your view:
<Grid.Resources>
<converters:EanListToStringConverter x:Key="EanListToString"/>
</Grid.Resources>
And finally in your BarCode
binding invoke this instance, something like this:
<DataGridTextColumn Binding="{Binding BarCode,
Converter={StaticResource EanListToString}}" Header="BarCodes" />