Search code examples
wpfwpfdatagrid

Make contents of data grid cell span multiple adjacent cell spaces


I want some of my datagrid cells to allow its contents to overflow and show over adjacent cells at runtime based on bound data. It should look like the attached image for instance ![Datagrid desired look for some cells]: https://drive.google.com/open?id=1SM_GQxT6zZ7q5oMBDJOMUkK_ct3fULg_

I have tried to put popups at runtime on the desired cells but popups create all sorts of problems when scrolling. I have also tried adjusting popup offset as the grid scrolls but it does not work smoothly and when the cell goes out of view the popup still shows on UI. So popup approach is not working. If somehow we could do it via template column cells and allowing the cell contents to optionally overflow based on data then the scrolling problem would not be there I think, but not sure how to go about this approach.


Solution

  • DataGrid is not really intended to be used this way, but a long-winded method to merge DataGrid cells can be found here.

    It may be easier to build with a standard Grid and utilize the ColumnSpan property to gain the desired effect. Not sure how your model is structured, but it could work quite well within MVVM.