This is a migrated thread and some comments may be shown as answers.

How do I bind to an object?

1 Answer 254 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 2
Martin asked on 11 Mar 2013, 01:14 PM
My objects has a RequiredCondition property.

RequiredCondition has Id, Name and so one.

I also has an Collection that is the ItemsSource.

How do I set up the binding? 

 <telerik:RadComboBox ItemsSource="{Binding Path=DataContext.Conditions, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type views:PropertyEditorView}}}"
                                                     SelectedItem="{Binding RequiredCondition}"
                                                     SelectedValue="{Binding RequiredCondition}"
                                                     DisplayMemberPath="Name" EmptyText="Select an Expression" />

 

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 13 Mar 2013, 04:19 PM
Hi Martin,

You could check the following help article which explains how to bind RadComboBox to a collection of custom objects:
http://www.telerik.com/help/wpf/radcombobox-populating-with-data-binding-to-object.html

Note that in this case the SelectedItem is of the type of the custom object and it should be set to one of the objects in the collection bound to the ItemsSource.   More information about selection of the ComboBox can be found here.

Greetings,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
ComboBox
Asked by
Martin
Top achievements
Rank 2
Answers by
Yana
Telerik team
Share this question
or