I'm facing a weird issue. I have a DataGrid
that I want to bind to ItemsSource
with MultiBinding
for a reason. While using simple binding to a DataTable
works well, I cannot get this to work with multibinding.
Simply put: the markup below works and renders the data table
<DataGrid Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" AutoGenerateColumns="True" IsReadOnly="True">
<DataGrid.ItemsSource>
<Binding Path="Mock.Value" Converter="{StaticResource CollectionToDataTableConverter}"></Binding>
</DataGrid.ItemsSource>
</DataGrid>
... while this does not really work - renders nothing
<DataGrid Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" AutoGenerateColumns="True" IsReadOnly="True">
<DataGrid.ItemsSource>
<MultiBinding Converter="{StaticResource CollectionToDataTableConverter}">
<Binding Path="Mock.Value" />
</MultiBinding>
</DataGrid.ItemsSource>
</DataGrid>
Notice that CollectionToDataTableConverter
implements both IValueConverter
and IMultiValueConverter
and simply passes the value
public class CollectionToDataTableConverter : IMultiValueConverter, IValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
return values?.FirstOrDefault();
}
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value;
}
// ...
}
Certainly the Mock.Value
property exists on the view model and is a simple DataTable
. Also, debugging proves that in both cases the converter returns a proper value.
Do you have any idea what is going on with this?
Thanks!