简体   繁体   English

c# wpf 数据网格合并单元格

[英]c# wpf datagrid merge cells

I'm trying to make DataGrid look like:我试图让DataGrid看起来像:

    --------------------------------------
    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。

    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?或者我应该做一个自定义控件?

The DataGrid is an ItemsControl adapted to represent cells in a row aligned in columns. DataGrid 是一个 ItemsControl,适用于表示按列对齐的行中的单元格。 But the basis is the same - the representation of the source elements (ItemsSource).但基础是相同的——源元素 (ItemsSource) 的表示。 In the case of the DataGrid, the representation is only row-by-row.在 DataGrid 的情况下,表示只是逐行的。 Since you need an interline representation, the DataGrid is not suitable for this.由于您需要行间表示,因此 DataGrid 不适合此用途。
You need either very deep intervention in the DatGrid template, or creating your own CustomControl (possibly derived from ItemsControl).您需要对 DatGrid 模板进行非常深入的干预,或者创建您自己的 CustomControl(可能派生自 ItemsControl)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM