开发者

WPF Data Binding to a non-property

I'd like to be able to bind WPF form elements to something other than a property, or at least, a more advanced property. As far as I know, WPF forms will only bind to public properties.

开发者_C百科

For example, making a seating chart for an airplane, its quite cumbersome to create properties for all the different passengers:

Plane.Seat1A
Plane.Seat1B
Plane.Seat2A
Plane.Seat2B
Plane.Seat3A
Plane.Seat3B
etc....

I would much rather bind to an array indexed by a string, for example:

<Label Content="{Binding Path=Seat["2A"] }" .... /> 

Is there anything that would approximate this behavior in WPF?


I believe your example will work if you remove the quotes from around "2A". Here is an article.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜