Cristian Chereches
Cristian Chereches

Reputation: 505

Why indexers don't work in WP8 bindings?

I am trying to bind an element from the view to a matrix in the view model. In the binding I want to use indexers so I can retrieve the element that I want. The following syntax does not work:

Fill="{Binding OwnBoard[0\,0], Converter={StaticResource BoardToBackConv}}"

If I remove the indexers, the binding is done and I get the value of the OwnBoard Property in the converter, but once I add the indexer, this does not work anymore and the converter is never called.

Do you know why this does not work in Windows Phone 8?

Upvotes: 1

Views: 87

Answers (1)

Kevin Gosse
Kevin Gosse

Reputation: 39007

Unfortunately, it looks like two-dimensional indexers aren't supported in Silverlight (Windows Phone .net apps are based on Silverlight): http://msdn.microsoft.com/en-us/library/cc645024(v=vs.95).aspx/html#indexdata

Only one-dimensional array indexing is supported.

As a workaround I would suggest to use a converter, but since you're already using one you'd have to find a way to chain two converters.

Upvotes: 2

Related Questions