In this particular case the ListCollectionView is actually bound correctly, but the control cannot generate the columns automatically due to the nature of the bound data.
You can, however, manually define the columns either in XAML or you can use the approach demonstrated in the Binding Columns From ViewModel to generate the columns in the ViewModel and bind them. I've gone ahead and implemented the first approach in the sample project you provided.
Please give this a try and let me know if any of these approaches would work for you.
The example with Binding Columns from ViewModel is unfortunately not good. If there is no way to use a ListCollectionView, I have to use a ObservableCollection. I think the problem is in the PropertyDescriptor class.
Dilyan Traykov
Telerik team
commented on 19 Oct 2022, 12:53 PM
An alternative approach I can suggest would be to handle the DataLoaded event of the control as follows to automatically generate the columns:
privatevoidGridView_DataLoaded(object sender, System.EventArgs e)
{
if (this.GridView.Columns.Count == 0)
{
var customTypeDescriptor = this.GridView.Items[0] as ICustomTypeDescriptor;
foreach (MyPropertyDescriptor prop in customTypeDescriptor.GetProperties())
{
this.GridView.Columns.Add(new GridViewDataColumn()
{
DataMemberBinding = new Binding(prop.Name),
Header = prop.Name
});
}
}
}
Can you please give this a try and let me know if this would work for you? If that is not the case, please specify why the approach suggested in the "Binding Columns from ViewModel" demo would not work for you so that I can try to suggest a viable solution.