All, I am creating a data set which is 'bound' to a DataGrid
at run-time. I pull in some data that is used to build a class which is inheriting from ObservableCollection<T>
. The class in question is
public class ResourceData : ObservableCollection<ResourceRow>
{
public ResourceData(List<ResourceRow> resourceRowList) : base()
{
foreach (ResourceRow row in resourceRowList)
Add(row);
}
}
public class ResourceRow
{
private string keyIndex;
private string fileName;
private string resourceName;
private List<string> resourceStringList;
public string KeyIndex
{
get { return keyIndex; }
set { keyIndex = value; }
}
public string FileName
{
get { return fileName; }
set { fileName = value; }
}
public string ResourceName
{
get { return resourceName; }
set { resourceName = value; }
}
public List<string> ResourceStringList
{
get { return resourceStringList; }
set { resourceStringList = value; }
}
}
I return a ResourceData
object from a method called BuildDataGrid()
, defined as
private ResourceData BuildDataGrid(Dictionary<string, string> cultureDict)
{
// ...
}
I then set the DataGrid
's ItemSource
to this ResourceData
object via
dataGrid.ItemSource = BuiltDataGrid(cultureDictionary);
however, this is not correctly expanding the ResourceStringList
within ResourceRow
. I get displayed:
My question is: How can I amend my ResourceRow
class to allow the DataGrid
to automatically read and display the contents of a ResourceData
object? I want to display each item in the ResourceStringList
in a separate column.
Thanks for your time.