I have a ViewModel with a WorkOrder object. The WorkOrder has an ObservableCollection(Of WorkItem). Each WorkItem has a WorkTypeId. The ViewModel also has an ObservableCollection(Of WorkType) exposed through a WorkTypeList property. The DataContext of the usercontrol is set to my viewmodel. I want to display a grid of WorkItems and show a dropdown list of WorkTypes for each WorkItem row. Here is the xaml for my grid:
<telerikGridView:RadGridView x:Name="itemsgrid" AutoGenerateColumns="False" CanUserFreezeColumns="False" CanUserReorderColumns="False" ShowGroupPanel="False" ItemsSource="{Binding WorkOrder.WorkItems, Mode=OneWay}" IsFilteringAllowed="False" >
<telerikGridView:RadGridView.Columns>
<telerikGridView:GridViewComboBoxColumn HeaderText="Work Type" Width="*" DisplayMemberPath="Name" SelectedValueMemberPath="Id" UniqueName="WorkTypeId" DataMemberPath="WorkTypeId"/>
</telerikGridView:RadGridView.Columns>
In code behind in the UserControl loaded event:
CType(itemsgrid.Columns(0), GridViewComboBoxColumn).ItemsSource
= CType(Me.DataContext, WorkOrderEditViewModel).WorkTypeList
I have a few issues:
1. If I manually create an observable collection of WorkType objects and assign it in place of the WorkTypeList property, the grid shows with correct WorkType selected but when I click on the cell to go into edit mode I get an unhandled error: An item with the same key has already been added.
2. If I use the WorkTypeList property which is filled async via a wcf service, the selected worktype does not appear and I get the same "already added" error when I click on the cell to go into edit mode.
I tried switching to using a GridViewDataColumn and setting the EditorSettings in code behind without any additional luck.
Please advise,
Heather