Hello, please I need help to display the data of this type List<List<string>> in the component RadGridView. Attached is a work in progress that I've started and I'm stuck.
To bind your models structure to the RadGridView, you can make a few adjustments in your code. You can set the ItemsSource of RadGridView to the Lines property in your CustomData class. Additionally, you could set AutoGenerateColumns to False since you are defining your own columns.
In your view model there is an error which comes from the GetYourData method. The error is Cannot.Convert type List<List<string>> to GridView_BindCollection.CustomData. This occurs because the Data property in your MainViewModel class is of type CustomData, but you are trying to assign a List<List<string>> to it. To fix this, you could create an instance of CustomData in your GetYourData() method and populate its Lines property.
private CustomData GetYourData()
{
CustomData customData = new CustomData();
customData.Lines = new List<CustomDataLine>
{
new CustomDataLine { Line = new List<string> {"Colonne1", "Colonne2", "Colonne3"} },
new CustomDataLine { Line = new List<string> {"Donnée1", "Donnée2", "Donnée3"} },
};
return customData;
}
In your scenario the DataContext will be null because you set it before population your view model Data property. In order to resolve this issue, you could reorder your MainWindow constructor like this: