Home > Enterprise >  c# wpf datagrid merge cells
c# wpf datagrid merge cells

Time:01-05

I'm trying to make DataGrid look like:

    --------------------------------------
    Point name  | Distance between points|
    --------------------------------------
        pt1     |------------------------|
    ------------|            10.45       |
        pt2     |------------------------|
    ------------|            8.55        |
        pt4     |------------------------|
    ------------|            4.89        |
        pt5     |------------------------|
    ------------|                        |

The grid is going to be binded to BindingList.

    BindingList<PointClass> points;
    class PointClass
    {
         public string Name { get; set;}
         public double DistToNextPoint { get; set;}
    }

Is it even possible with datagrid? Or should I make a custom control?

CodePudding user response:

The DataGrid is an ItemsControl adapted to represent cells in a row aligned in columns. But the basis is the same - the representation of the source elements (ItemsSource). In the case of the DataGrid, the representation is only row-by-row. Since you need an interline representation, the DataGrid is not suitable for this.
You need either very deep intervention in the DatGrid template, or creating your own CustomControl (possibly derived from ItemsControl).

  • Related