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. DataGrid with DataGridTemplateColumns - Cannot create new rows

DataGrid with DataGridTemplateColumns - Cannot create new rows

Scheduled Pinned Locked Moved WPF
wpfcomcollaborationhelp
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
    Mc_Topaz
    wrote on last edited by
    #1

    I have a DataGrid with a couple of DataGridTemplateColumns. When I try to hit the Enter-key on my keyboard there is no new row created in the DataGrid. I have other DataGrids with columns which are not DataGridTemplateColumns and I can then create new rows by hitting the Enter-key. So I assume the DataGridTemplateColumns in some way causing the problem. I have made a reproducible code and I have made it public in this GIT-Gist. * I use Fody PropertyChanged to handle all the INotificationPropertyChanged in my view models. * The code should just be copy-and-paste. The bindings between the View and the ViewModels also don't seem to work :S But if you uncomment the row in the ViewModel's construcotor (please see line 60 in the MainWindow.xaml.cs), a new row in the DataGrid will be created. With this row, the bindings works as expected. I cannot understand why. Here is the XAML-code. It maybe enough for you with only the XAML-code to solve this problem.

    L 1 Reply Last reply
    0
    • M Mc_Topaz

      I have a DataGrid with a couple of DataGridTemplateColumns. When I try to hit the Enter-key on my keyboard there is no new row created in the DataGrid. I have other DataGrids with columns which are not DataGridTemplateColumns and I can then create new rows by hitting the Enter-key. So I assume the DataGridTemplateColumns in some way causing the problem. I have made a reproducible code and I have made it public in this GIT-Gist. * I use Fody PropertyChanged to handle all the INotificationPropertyChanged in my view models. * The code should just be copy-and-paste. The bindings between the View and the ViewModels also don't seem to work :S But if you uncomment the row in the ViewModel's construcotor (please see line 60 in the MainWindow.xaml.cs), a new row in the DataGrid will be created. With this row, the bindings works as expected. I cannot understand why. Here is the XAML-code. It maybe enough for you with only the XAML-code to solve this problem.

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

      Can't think of too many examples that use buttons and sliders in a data grid; data sources called "path" and "value"; and columns that are read-only. Worlds in collision.

      It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

      M 1 Reply Last reply
      0
      • L Lost User

        Can't think of too many examples that use buttons and sliders in a data grid; data sources called "path" and "value"; and columns that are read-only. Worlds in collision.

        It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

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

        The code I gave, is only an example how to reproduce the problem. A real-life example of a button, textboxes and a slide is irrelevant. My actual code contains of a button, a textbox, two numeric up down controls and a date picker in each row. All columns, except the textbox, are DataGridTemplateColumns. Is there a solution to my problem?

        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