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. GridView displaying 2 columns with custom controls

GridView displaying 2 columns with custom controls

Scheduled Pinned Locked Moved WPF
questioncsharpwpfdata-structureshelp
3 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
    Gareth H
    wrote on last edited by
    #1

    I am new to WPF, so bear with him. I want to have a GridView with 2 columns, displaying custom controls, which has X amount of rows. The data i am given is in a list format, which i then need to display as follows: i want to insert item 1 in column 1 and item 2 in column 2 for row 1. And then item 3 in column 1 and item 4 in column 2 for row 2, and so on - (Think of it a bit like a photo gallery) The custom control will display the details for each item, which i have already created. The problem i have is, how do i bind the data to the GridView. My initial idea was to split the data into rows, i.e.: have several lists, that contain 2 items. This allows me to know that item 1 is for column 1 and item 2 is for column 2, i can then work my way through all the lists and end up with all the rows populated with the custom controls. However, i cant work out how to programmtically add a new row, which should have a control in each column. Am i going about it the right way? Or barking up the wrong tree... Hopefully i've made sense. Cheers.

    Regards, Gareth. (FKA gareth111)

    G 1 Reply Last reply
    0
    • G Gareth H

      I am new to WPF, so bear with him. I want to have a GridView with 2 columns, displaying custom controls, which has X amount of rows. The data i am given is in a list format, which i then need to display as follows: i want to insert item 1 in column 1 and item 2 in column 2 for row 1. And then item 3 in column 1 and item 4 in column 2 for row 2, and so on - (Think of it a bit like a photo gallery) The custom control will display the details for each item, which i have already created. The problem i have is, how do i bind the data to the GridView. My initial idea was to split the data into rows, i.e.: have several lists, that contain 2 items. This allows me to know that item 1 is for column 1 and item 2 is for column 2, i can then work my way through all the lists and end up with all the rows populated with the custom controls. However, i cant work out how to programmtically add a new row, which should have a control in each column. Am i going about it the right way? Or barking up the wrong tree... Hopefully i've made sense. Cheers.

      Regards, Gareth. (FKA gareth111)

      G Offline
      G Offline
      Gareth H
      wrote on last edited by
      #2

      I've changed my idea to have to have 2 stack panels, as this seems more fitting.

      Regards, Gareth. (FKA gareth111)

      G 1 Reply Last reply
      0
      • G Gareth H

        I've changed my idea to have to have 2 stack panels, as this seems more fitting.

        Regards, Gareth. (FKA gareth111)

        G Offline
        G Offline
        Gareth H
        wrote on last edited by
        #3

        Solved.

        Regards, Gareth. (FKA gareth111)

        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