我希望能够将 WPF 表单元素绑定(bind)到属性之外的其他内容,或者至少绑定(bind)到更高级的属性。据我所知,WPF 表单只会绑定(bind)到公共(public)属性。
例如,为飞机制作座位表,为所有不同的乘客创建属性非常麻烦:
Plane.Seat1A
Plane.Seat1B
Plane.Seat2A
Plane.Seat2B
Plane.Seat3A
Plane.Seat3B
etc....
我宁愿绑定(bind)到一个由字符串索引的数组,例如:
<Label Content="{Binding Path=Seat["2A"] }" .... />
在 WPF 中有什么可以近似这种行为的吗?
最佳答案
我相信如果您删除“2A”周围的引号,您的示例将会起作用。这是 an article .
关于c# - WPF 数据绑定(bind)到非属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4856319/