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. XamDataGrid columns

XamDataGrid columns

Scheduled Pinned Locked Moved WPF
wpfquestionwcfregexarchitecture
3 Posts 2 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.
  • M Offline
    M Offline
    michaelgr1
    wrote on last edited by
    #1

    Hello, I am writing my app using MVVM pattern. I have a XamDataGrid and i need to display in it my ViewModels. I have a collection of VMs so each VM should be a row in the DataGrid. Also each VM has a child VM that has collection of VMs. Each such VM contains 3 properties- Field, Value and operator. I need the DataGrid to have dynamic fields according to the fields i have (in the collection of "small" VMs). each cell will contain the right value from the small VM under the right field . The operator value should be displayed in another operator column. All operators are the same for the VMs related to same row in the DataGrid. Currently i did it using dependency property- i bind the collection of VMs and than build a DataTable with dynamic columns and set is as DataSource of the dataGrid. The thing is that it is fine if my DataGrid is read-only. But i need an option to change the DataGrid values . If i will do it with current code (with dependency property) i don't know what VM to change (because the DataGrid cell is not bind to any object). How can i still solve this so it will work with binding?

    L 1 Reply Last reply
    0
    • M michaelgr1

      Hello, I am writing my app using MVVM pattern. I have a XamDataGrid and i need to display in it my ViewModels. I have a collection of VMs so each VM should be a row in the DataGrid. Also each VM has a child VM that has collection of VMs. Each such VM contains 3 properties- Field, Value and operator. I need the DataGrid to have dynamic fields according to the fields i have (in the collection of "small" VMs). each cell will contain the right value from the small VM under the right field . The operator value should be displayed in another operator column. All operators are the same for the VMs related to same row in the DataGrid. Currently i did it using dependency property- i bind the collection of VMs and than build a DataTable with dynamic columns and set is as DataSource of the dataGrid. The thing is that it is fine if my DataGrid is read-only. But i need an option to change the DataGrid values . If i will do it with current code (with dependency property) i don't know what VM to change (because the DataGrid cell is not bind to any object). How can i still solve this so it will work with binding?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Don't use dynamic columns. You should template out each column and set up the binding for each one seperately.

      Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.

      M 1 Reply Last reply
      0
      • L Lost User

        Don't use dynamic columns. You should template out each column and set up the binding for each one seperately.

        Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.

        M Offline
        M Offline
        michaelgr1
        wrote on last edited by
        #3

        Right, But i don't know the number of fields i have.

        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