WPF数据绑定到非属性

abe*_*nky 1 c# wpf binding

我希望能够将WPF表单元素绑定到除属性之外的其他内容,或者至少是更高级的属性.据我所知,WPF表单只会绑定到公共属性.

例如,为飞机制作座位表,为所有不同乘客创建物业非常麻烦:

Plane.Seat1A
Plane.Seat1B
Plane.Seat2A
Plane.Seat2B
Plane.Seat3A
Plane.Seat3B
etc....
Run Code Online (Sandbox Code Playgroud)

我宁愿绑定到一个由字符串索引的数组,例如:

<Label Content="{Binding Path=Seat["2A"] }" .... /> 
Run Code Online (Sandbox Code Playgroud)

在WPF中是否有任何与此行为相似的内容?

Jak*_*son 5

我相信如果您从"2A"左右删除引号,您的示例将起作用.这是一篇文章.