简体   繁体   中英

How can I set DisplayMemberPath as the value of a specific key in a keyvaluepaircollection attribute of my ItemsSource?

I have a Radcombobox that has ItemsSource set to be bound to a List. This Entity class ( http://msdn.microsoft.com/en-us/library/microsoft.xrm.sdk.entity_members.aspx ) has as one of its properties Attributes, which is an AttributeCollection ( http://msdn.microsoft.com/en-us/library/microsoft.xrm.sdk.attributecollection_members.aspx ), which as far as I can tell is just a KeyValuePair. there is a specific key in there with a value that I need to display. I have tried just entering the name of the attribute, I've tried using GetAttributeValue('keyname') , I've tried using Attributes['keyname'].value , I've tried Attributes.TryGetValue('keyname') , I've tried Attributes['keyname'] , but I cannot get it to work.

A further challenge is that I don't always know this field at designtime. I know it for 3 of my comboboxes, but the 4th combobox doesn't always contain the same Entity. I do know the key at runtime though.

So how can I do this?

Edit: I've checked the output window during the binding retrieval process. It says that the key is not found in the dictionary, even though I've verified that that name is actually in there.

I have figured out why it doesn't work.

Apparently, if you want to use a dictionary key, you need to access it as [keyname], without any single or double quotes. So I used Attributes[keyname], and it worked.

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