I am using WPF Telerik controls in a WPFApplication using MVVM pattern.
All controls binding is throw ObservableCollections, for the RadGrid the binding is fine but for the GridViewComboBoxColumn binding it's not.
In fact GridViewComboBoxColumn is binding to another ObservableCollections via
ItemsSource="{Binding MyCollection}"
DataMemberBinding="{Binding Property}"
DisplayMemberPath="Label"
SelectedValueMemberPath="Value"
but it doesn't work.
Can GridViewComboBoxColumn support another collection binding other than RadGrid Collection Binding ??
Thx
6 Answers, 1 is accepted
For such scenarios GridViewComboBoxColumn exposes the ItemsSourceBinding property.
In short : ItemsSourceBinding is an alternative to ItemsSource in case you need a separate combobox itemssource for each row as well as you need to bind in XAML rather than set ItemsSource in codebehind.The syntax would be something like :
ItemsSourceBinding="{Binding {StaticResource MyCollection}}"
or if the 'MyCollection' is a property of the row item ( your business object)
ItemsSourceBinding="{Binding MyCollection}"
* For example if you bind the RadGridView to a collection of Continent objects and each Continent has a Countries collection property you may use:
ItemsSourceBinding="{Binding Countries}"
And if the Countries collection is not a property of the Continent object , the you may provide the collection as a static resource and use:
ItemsSourceBinding="{Binding {StaticResource Countries}}"
All the best,
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.
My GridView is binding to "VeiclesUsage" having:
<telerik:RadGridView AddingNewDataItem="grd_geral_AddingNewDataItem" AutoGenerateColumns="False" CanUserInsertRows="True" Margin="6,285,0,0" Name="grd_geral" ShowGroupPanel="False">
<telerik:RadGridView.Columns>
<telerik:GridViewComboBoxColumn DataMemberBinding="{Binding StaffID}" DisplayMemberPath="Name" Header="STaff" IsComboBoxEditable="True" SelectedValueMemberPath="ID" UniqueName="tipo_dist" Width="100" />
<telerik:GridViewComboBoxColumn DataMemberBinding="{Binding VehicleID}" DisplayMemberPath="Name" Header="Vehicle" IsComboBoxEditable="True" SelectedValueMemberPath="ID" UniqueName="Res" Width="150*" />
...
Is possible to use ItemsSourceBinding to when I chose The STaff from the Combobox he Selectes automatic the vehicles associated to him in the Staff/Vehicles table?
The itemsSource of both combobox are loaded like this:
DirectCast(Me.grd_geral.Columns("tipo_dist"), GridViewComboBoxColumn).ItemsSource = mycontext.CBO_Staff
DirectCast(Me.grd_geral.Columns("Res"), GridViewComboBoxColumn).ItemsSource = mycontext.CBO_Vehicles
Tanks in advance
Please take a look at this blog post for a reference.
All the best,
Maya
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.
You can try using Telerik VB to C# converter.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>