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.
精彩评论