Good morning
I'm trying to display two fields of an object on a label within a CollectionView.
The problem I have is that I don't know how I can bind the object so I can concatenate the fields I need into a custom converter.
a code example for a better understanding of the problem
<CollectionView
ItemsSource="{Binding Purchases}"
>
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.65*"/>
<ColumnDefinition Width="0.35*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label Grid.Column="0" Grid.Row="0" Text="{Binding ??????, Converter={StaticResource PurchaseNameAndPriceConverter}}" ></Label>
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
class PurchaseNameAndPriceConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
Purchase p = (Purchase)value;
return p.SellerName + p.Total.ToString() + " €";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
I tried to bind with Binding (dot) but in the converter the object does not arrive,
I've been looking for information about this and I haven't found anything.
Could someone help me about this?
