Silverlight / WPF - WPF datagrid as combobox dropdown
Asked By sabaresh on 18-Mar-10 05:44 AM
I went through this article and thought of creating a WPF datagrid as combobox dropdown as a usercontrol.
I am facing some of the problems while selecting an item in the datagrid and displaying it in the combo box. Since it is the usercontrol I made it as generic so that anyone can use it. Actually how to set the usercontrol's combobox's selected property to the corresponding item in the datagrid???
Thanks & Regards
You'd want to expose a public SelectedItem property
Robbe Morris replied to sabaresh on 18-Mar-10 08:51 AM
on your user control that raised the PropertyChangedEvent. Inside the property, you'd set the selected item on the combobox. Then, anyone using your control could databind to that property.
sabaresh replied to Robbe Morris on 18-Mar-10 09:51 AM
Could you please elaborate it ??
sabaresh replied to Robbe Morris on 19-Mar-10 03:12 AM
As you told I got the selected item but the problem I'm facing now is since the selected item is an object, I wanna display only the one dataitem from that object in that combobox. I donno how to bind only one item to the text property at the runtime and how to display it. Now it's displaying the object name and not the item.
Please please help me to solve this issue.
You'd want to expose SelectedValue and/or SelectedText as well
Robbe Morris replied to sabaresh on 19-Mar-10 07:59 AM
and set them in your user control.
sabaresh replied to Robbe Morris on 21-Mar-10 01:22 PM
Thanks for your help.
Even after exposing them still I'm getting the same problem. I'm getting the objectname in the checkbox's text. Is there anything else I wanna do?
You could check this article
Michael Detras replied to sabaresh on 22-Mar-10 06:26 PM
Please check this new article
. This uses a custom control instead of a user control. Hope this helps.