Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Add content to a GridViewRowPresenter

Add content to a GridViewRowPresenter

Scheduled Pinned Locked Moved WPF
csharpwpfquestiondata-structureshelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    GDavy
    wrote on last edited by
    #1

    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 the GridViewRowPresenter 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 file

    grdViewHeader.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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups