Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
315
HELP - How to display (variable columns) data in grid correctly?
posted

Hi,

I've got a class to hold a variable number of column values as shown below:

public class DataEntry
{
    // List of columns and their values
    private List<string> columns = new List<string>();
    public List<string> Columns
    {
        get {return columns;}
        set {columns = value;}
    }
}

And I've got a list of them in:

List<DataEntry> records = new List<DataEntry>();

How do I set XamDataGrid up such that when I do xdgGrid.DataSource = records, each column will be displayed as an individual column, instead of being nested?

 Thanks

  • 6867
    posted

     XamDataGrid creates columns out of properties on the data source objects.  It cannot create columns out of a list of strings.  What you could do, however, is create a DataTable whose DataColumns are based on that list of strings, and then bind the XamDataGrid to the DataTable.