简体   繁体   中英

How can I do compiled binding or x:Bind to indexed property using string as an index?

I'm trying to use compiled binding I have a property Errors that I used to bind using the regular binding like {Binding Errors[PropertyName]} . However, when I tried to use {x:Bind VM.Errors[PropertyName]} , I got this error

"Invalid binding path 'VM.Errors[PropertyName]' : Expected a digit"

I also tried to use quotes like VM.Errors['PropertyName'] but it does'nt solve the problem.

It does not work. Microsoft writes:

{Binding Groups[2].Title}

Binds to the specified item in the collection. Only integer-based indexes are supported.

See: https://msdn.microsoft.com/en-us/library/windows/apps/mt210946.aspx at the end of the page. I event tried implementing IReadOnlyDictionary oe IDictionary, but no success.

Its interessting because on https://msdn.microsoft.com/en-us/library/windows/apps/mt185586.aspx they say:

For example, consider a business object where there is a list of "Teams" (ordered list), each of which has a dictionary of "Players" where each player is keyed by last name. An example property path to a specific player on the second team is: "Teams 1 .Players[Smith]". (You use 1 to indicate the second item in "Teams" because the list is zero-indexed.)

Update

My support case at Microsoft connnect was closed. They write:

Thank you for reporting this issue as well as providing a sample project. The suggested scenario was not supported in Windows 10 RTM. We are however considering adding such support to a future update to Windows 10.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM