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


1 Answer 40 Views
This is a migrated thread and some comments may be shown as answers.
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
Telerik team
answered on 14 Mar 2012, 04:12 PM

 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:

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

I hope that this helps.

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