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

Binding To ComboBox in Grid

4 Answers 235 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 17 Jan 2009, 10:52 PM
I am trying to get a combobox to work inside a grid.  the combobox uses a collection as it's datasource.  I have the combobox displaying the drop down data, but it currently does not store the selected value.  here is the xaml snippet

                     <DataTemplate x:Name="GenderTypeDataTemplate" > 
                                <telerikInput:RadComboBox  x:Name="theGenderTypeLookup"    
                                                           ItemsSource="{Binding Source={StaticResource MyGenderTypes}}"    
                                                           DisplayMemberPath="Description" 
                                                           SelectedValuePath="GenderType" 
                                                           Height="20" Grid.Column="2" MinWidth="40" /> 
                        </DataTemplate> 

in the collection of GenderTypes ("MyGenderTypes"), Description is the property being displayed in the combobox.

the entity property that will be assigned the selected combobox value is named "GenderType".

what is need to understand is how to bind the selected value of the combobox to the entity property "GenderType" (in XAML).

Also, how would I reference the comboBox in the code-behind file?  When defining it inside the data template, it doesn't show up as a referenceable item in intellisence.

Thanks alot,
Jeff

4 Answers, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 20 Jan 2009, 01:04 PM
Hello Jeff,

Does the following work for you?
SelectedValue="{Binding GenderType}"

Usually the DataContext of the item containers in an ItemsControl is the corresponding data item, so you could write bindings as the one above.

Visual Studio does not generate members for controls in DataTemplates, because the templates are instantiated many times. Why do you need to reference the combo box in the code behind? I could provide an example or suggestion depending your scenario.

Regards,
Valeri Hristov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jeff
Top achievements
Rank 1
answered on 23 Jan 2009, 02:26 PM
Thanks, I was able to get the RadComboBox working within the Silverlight grid.  Could you provide an example of the xaml for defining the RadComboBox as a column within the RadGrid?
0
Jeff
Top achievements
Rank 1
answered on 26 Jan 2009, 04:16 PM
Pls. disregard the previous request.
0
Amit
Top achievements
Rank 1
answered on 07 Nov 2012, 12:59 AM
hi Jeff,

Can u please provide a sample code to put dropdown into grid

thanks,
Amit
Tags
ComboBox
Asked by
Jeff
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Jeff
Top achievements
Rank 1
Amit
Top achievements
Rank 1
Share this question
or