【发布时间】:2018-04-27 17:41:04
【问题描述】:
我有一个类InfoField 包含各种类型的成员。我想将ObservableCollection<InfoField> 属性绑定到某种 WPF 控制器。
- 类成员水平列出,所有集合元素垂直列出。
- 列和行都有标题。
- 我可以为各种数据类型应用不同的数据模板。
- 我可以按列标题(例如 ShowRpm)来选择它下面的所有复选框。
我一直在使用 ListView 进行测试,但我不确定这是正确的方法。据我所知,我很难使用ListView 获得第二点和第四点。任何人都知道为此使用哪个控件?
ShowRpm ShowCurrent ShowTemperature Direction
Motor1 (checkbox) (checkbox) (checkbox) (combobox)
Motor2 (checkbox) (checkbox) (checkbox) (combobox)
Motor3 (checkbox) (checkbox) (checkbox) (combobox)
...
MotorN (checkbox) (checkbox) (checkbox) (combobox)
C#:
public class InfoField {
public bool ShowRpm { get; set; }
public bool ShowCurrent { get; set; }
public bool ShowTemperature { get; set; }
public Direction Direction { get; set; }
}
public enum Direction {
Horizontal,
Vertical
}
【问题讨论】:
-
我会考虑使用
DataGridView。您可能需要进行一些定制才能满足您的所有要求,但这应该是一个好的开始。