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

GridViewComboBoxColumn

1 Answer 65 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 14 Mar 2012, 03:06 PM
I have a GridView that I'm binding to a custom collection of custom objects.  In this GridView, I need to bind a ComboBoxColumn to a set of values in a different collection.

For example,

I've created a VB.NET List(of String) that holds the names of states. My class that the grid is bound to has a State property.  I want to bind the states column to that List(of String) collection so that the user sees the dropdown of all available options when editing the particular record.


My List(Of String) is defined in a Module, and thus accessible as a global variable in the app.  The custom class comes from a different library, and doesn't know anything about the list of states.

  I can't seem to get the ItemsSource of the ComboBoxColumn to bind to something defined in a Module.  Is such a scenario allowed?

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 14 Mar 2012, 04:12 PM
Hello,

 You can specify the Source for the ItemsSource binding.
For example you can define the Source as a static resource and use it as follows:

<UserControl.Resources>
    <local:MainPageViewModel x:Key="mainPageViewModel" />
</UserControl.Resources>
...
<telerik:GridViewComboBoxColumn Header="Category"
            DataMemberBinding="{Binding CategoryID}"
            ItemsSource="{Binding Path=Categories, Source={StaticResource mainPageViewModel}}"
            DisplayMemberPath="CategoryName"
            SelectedValueMemberPath="CategoryID" />

I hope that this helps.

Greetings,
Didie
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
GridView
Asked by
Thomas
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or