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

[Solved] How to set the itemsource of combobox column

2 Answers 220 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jayachandran P
Top achievements
Rank 1
Jayachandran P asked on 11 Sep 2009, 02:33 PM
How can we set the itemsource for a gridviewcomboxcolumn from xaml?
The context of the parent grid has a collection property which needs to be set as the itemsource.
Can we do this from xaml?

http://www.telerik.com/help/silverlight/gridview-gridviewcomboboxcolumn.html


XAML Copy Code
<telerik:RadGridView x:Name="RadGridView1" AutoGenerateColumns="False" >
  
<telerik:RadGridView.Columns>
   
<telerik:GridViewComboBoxColumn HeaderText="Country"
   
SelectedValueMemberPath="ID"
   
DisplayMemberPath="Name"
   
DataMemberBinding="{Binding CountryID}" />

  
</telerik:RadGridView.Columns>
 
</telerik:RadGridView>

 

 

C# Copy Code
GridViewComboBoxColumn comboColumn = new GridViewComboBoxColumn();
             comboColumn.HeaderText =
"Country";
             comboColumn.DataMemberBinding =
new Binding("CountryID");
             comboColumn.ItemsSource = GetCountries();
             comboColumn.DisplayMemberPath =
"Name";
             comboColumn.SelectedValueMemberPath  =
"ID";
             
this.RadGridView1.Columns.Add(comboColumn);

private System.Collections.IEnumerable GetCountries()
         {
             List<Country> countries =
new List<Country>();
             countries.Add(
new Country(){ID=0, Name = "Germany"});
             countries.Add(
new Country(){ID=1, Name = "Spain"});
             countries.Add(
new Country(){ID=2, Name = "UK"});
             
return countries;
         }


Thanks
Jay

2 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 16 Sep 2009, 02:53 PM
Hi Jayachandran P,

Unfortunately this is not possible with the current version. However I find your request absolutely reasonable. I have already taken the steps necessary and we will have this fixed for our very next version. Meanwhile the only  workaround I may suggest is to set this property from codebehind.


Regards,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Collin
Top achievements
Rank 1
answered on 17 Dec 2009, 07:58 PM
Thanks Jay for posting your code.  Even though you were asking a question, your code snippet helped me figure out a way to bind to enums with a little conversion to a dictionary.  Muchas gracias!
Tags
GridView
Asked by
Jayachandran P
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Collin
Top achievements
Rank 1
Share this question
or