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

Binding to object with foreign key

1 Answer 159 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jeanne
Top achievements
Rank 2
Jeanne asked on 19 Mar 2009, 07:38 PM
I have used the silverlight combobox successfully to bind to an object that contains 3 properties - ID is the foreign key, Title is what should be displayed in the drop down, Description is what should be displayed in a tooltip (I'm not concerned about the tooltip in the combobox).

This is how I accomplished it with the silverlight combobox:

                DisplayMemberPath="Title"
                ItemsSource="{Binding Path=ProjectListProvider.LocationList}"
                SelectedItem="{Binding Path=ProjectLocationName, Mode=TwoWay}">

The DataContext was set to an object that held a ProjectListProvider object and a ProjectLocationName object (that object is of a base type that had ID, Title, Description).  Then I overrode the Equals/GetHashCode methods in the ProjectLocationName's base class.  An example of this is in the blog posting: http://weblogs.asp.net/manishdalal/archive/2008/09/28/combobox-in-datagrid.aspx. 

Now I would like to switch to the RadComboBox, so all of my controls can be themed using the (very nice)            StyleManager.ApplicationTheme = ThemeManager.FromName("Vista").  I need some guidance.  I noticed that you have implemented SelectedValue and SelectedValuePath, and there is also the telerik:TextSearch.TextPath that is shown in one of your examples.  I'm not sure which of these to use.  I'm resorting to trial and error and I haven't hit on the correct solution.

If I leave the xaml given above, the popup item that is highlighted may not be displayed (you have to scroll to find it).  Also, the ProjectLocationName object held in the DataContext object does not appear to be updating correctly.

Any help or suggestions would be great.
Jeanne 



1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 23 Mar 2009, 04:01 PM
Hi Jeanne,

I'm sorry for the late response.

Can you send us sample project so that we can get better understanding of what you try to achieve. The SelectedValuePath property provides a way to specify a SelectedValue for the SelectedItem in a RadComboBox. The SelectedItem represents an object in the Items collection and the RadComboBox displays the value of a single property of the selected item. The SelectedValuePath property specifies the path to the property that is used to determine the value of the SelectedValue property.
If you are able to do it with Silverlight ComboBox then you should be able to do it with RadComboBox.
As for the scrolling issue - this is a bug that will be fixed in the next service pack.

Waiting for your response.

Kind regards,
Hristo
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
ComboBox
Asked by
Jeanne
Top achievements
Rank 2
Answers by
Hristo
Telerik team
Share this question
or