Add content to a GridViewRowPresenter
-
I might be missing something basic here, but I am new to WPF ... Anyway, I am trying to create a dynamic list (nr of columns and data depends on content of a file). I used the
GridViewHeaderRowPresenter
for the header (displays fine) and am trying to use theGridViewRowPresenter
to add rows to the list. The problem I have is that the columns of my GridViewRowPresenter all show Object[] Array in stead of the actual data. Since the makeup of the list is dynamic the xaml part of the list is actually only this:<stackpanel x:name="MyGridViewList" orientation="Vertical" > <gridviewheaderrowpresenter x:name="grdViewHeader" columnheadercontainerstyle="{StaticResource MyHeaderStyle}" /> </stackpanel>
In C# behind I do the following
GridViewColumnCollection colCollection = new GridViewColumnCollection();
//.... Here I fill all the collumns. reading stuff from a filegrdViewHeader.Columns = colCollection; //set the columns in the header -> This is working like a charm
//Here is the part where most likely I do something wrong
//RowParser is an object that parses rows from the file.
//The GetNextRow function returns an array of objects (size of array is equal to nr of columns)
object rowObj;
while( null != (rowObj = RowParser.GetNextRow()) )
{
GridViewRowPresenter rowPresenter = new GridViewRowPresenter();
rowPresenter.Columns = colCollection;
rowPresenter.Content = rowObj;
MyGridViewList.Children.Add(rowPresenter);
}The object array that the GetNextRow returns is an array that can contain a mix of both strings and integers. It was my impression that automatically the rowPresenter would convert each member to a string value. This is not the case however. Can someone guide me to what is wrong here? Thanks in advance, Davy