0
votes

My scenario:

I have a Telerik Silverlight RadGridView With some columns, and one of them is

<telerik:RadGridView x:Name="Grid1" DataContext="{StaticResource ViewModelDailyReport}" IsSynchronizedWithCurrentItem="True" ScrollMode="RealTime"  AutoGenerateColumns="false" ItemsSource="{Binding LogBookItems}" IsReadOnly="false"   Visibility="Visible" >
[...]
<telerik:GridViewComboBoxColumn
                Header="My Activity"
                DataMemberBinding="{Binding Activity.ID, Mode=TwoWay}"
                SelectedValueMemberPath="ID"
                DisplayMemberPath="Name"
                ItemsSource="{StaticResource ViewModelActivities}">
</telerik:GridViewComboBoxColumn>
[...]

So I Have a TwoWay binding on a Collection of Items in a ViewModel.

All works fine, except when I insert a new item (with RadGrid BeginInsert command): when user chooses an item from the dropdown, it is always blank in the cell...

The bound collection has a new item (on insert event), but there is no way to bind the newly added item with combobox.

What is the trick?

Thanks

1

1 Answers

0
votes

Make sure you have a default constructor in the LogBookItem class.

In the default constructor, you can initialize your default values and also create a new Activity instance, since you are binding to it's ID.

public LogBook()
{
 //initialize default values
 this.CreationDate = DateTime.UtcNow;
 this.Activity = new Activity(); //Activity.ID will equal 0
}