我在 WPF 中使用分组(通过 CollectionViewSource 中的 PropertyGroupDescription)并在绑定的 DataGrid 中显示分组集合。
通常(如在此 MSDN 示例中)这样的 DataGrid 将显示列标题,然后是每个组标题(在 GroupStyle.Containerstyle 中定义),然后是给定组中的数据行。这是一个快速的视觉效果:
+================================================== ====+ | 列标题1 | 列标题2 | 列标题3 | +-----------------+-----------------+------------- ----+ | A组 | +-------------------------------------------------- ----+ | A_Value_11 | A_Value_12 | A_Value_13 | +-------------------------------------------------- ----+ | A_Value_21 | A_Value_22 | A_Value_23 | +-----------------+-----------------+------------- ----+ | B组 | +-------------------------------------------------- ----+ | B_Value_11 | B_Value_12 | B_Value_13 | +-------------------------------------------------- ----+ | B_Value_21 | B_Value_22 | B_Value_23 | +================================================== ====+
有没有办法让 DataGrid 列标题在每个组标题之后出现/重复?
从视觉上看,这更像是我想要的:
+================================================== ====+ | A组 | +-------------------------------------------------- ----+ | 列标题1 | 列标题2 | 列标题3 | +-------------------------------------------------- ----+ | A_Value_11 | A_Value_12 | A_Value_13 | +-------------------------------------------------- ----+ | A_Value_21 | A_Value_22 | A_Value_23 | +-----------------+-----------------+------------- ----+ | B组 | +-------------------------------------------------- ----+ | 列标题1 | 列标题2 | 列标题3 | +-------------------------------------------------- ----+ | B_Value_11 | B_Value_12 | B_Value_13 | +-------------------------------------------------- ----+ | B_Value_21 | B_Value_22 | B_Value_23 | +================================================== ====+
有没有可能在没有太多麻烦的情况下做到这一点?