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
210
How to use a a generic array/collection of object arrays as source for xamGrid
posted

Here's my situation: I have a very basic need to populate the xamGrid with rows of data that (for a number of functional reasons) can be of varying column counts and content.  Effectively, what I have is a collection of object arrays (of varying data types) coming out of variable (user-defined) sql select queries that I want to use to populate rows in the grid.

What I can't figure out is a simple way to populate the grid from these arrays.  I've tried wrapping them in a class with a generic, indexed property and then manually generating the fields in the field layout to pull from that property.  But I can't get it to work with either bound or unbound fields.  It creates a row in the grid for each row/object in the underlying data, but doesn't populate the cells.

The data is always read-only, so there's really no need for two-way binding.  I can do it using a datatable quite easily, but the data table involves processing and memory overhead that is really unnecessary to my purposes (mainly because it's always going to be read-only).  So I'd like to see if I can do it with a datareader building an in-memory array or collection of arrays of data instead.

We're long-time users of the COM/VB6 grid from Sheridan/Infragistics and this approach has worked well for us; if I can figure out a way to do it with the WPF grid, I'll be in absolute heaven.

Parents
No Data
Reply
  • 210
    Verified Answer
    posted

    Well, I figured it out.  The problem was that I wasn't using the right syntax for binding to an Indexer property.  Once I implemented the property as the default for the underlying class and set the path of the unbound columns to "[index]" it works like a charm.  And with only a few hundred records, its already faster and more responsive than using a data table.

Children
No Data