Binding To ComboBox in Grid

5 posts, 0 answers
  1. Jeff
    Jeff avatar
    22 posts
    Member since:
    Nov 2008

    Posted 17 Jan 2009 Link to this post

    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}}"    
                                                               Height="20" Grid.Column="2" MinWidth="40" /> 

    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,
  2. Valeri Hristov
    Valeri Hristov avatar
    2252 posts

    Posted 20 Jan 2009 Link to this post

    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.

    Valeri Hristov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Jeff
    Jeff avatar
    22 posts
    Member since:
    Nov 2008

    Posted 23 Jan 2009 Link to this post

    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?
  4. Jeff
    Jeff avatar
    22 posts
    Member since:
    Nov 2008

    Posted 26 Jan 2009 Link to this post

    Pls. disregard the previous request.
  5. Amit
    Amit avatar
    4 posts
    Member since:
    Nov 2012

    Posted 06 Nov 2012 Link to this post

    hi Jeff,

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

Back to Top