This project has moved and is read-only. For the latest updates, please go here.

Performance issues and problems with implementing ComboBox in version

Aug 14, 2013 at 10:40 AM
Edited Aug 14, 2013 at 10:41 AM

I downloaded version and am in the process of implementing it for my application that has datagrids with up to 20 columns and 10,000 rows, and uses SQL Server 2012, with 35 tables.

Another great work! I am particularly interested in the validation methods.

I have noticed the following:

1) For most changes I make to the code, I need to "clean" and "rebuild" the corresponding project for the changes to take effect. That wasn't the case in previous version.

2) Running the program in the debug mode noticeably takes longer than before.

3) Adding and removing records are done with a longer pause, even with small tables.

I am not sure if these are related to the Code First approach, validation or other factors.

Also, I would highly appreciate your assistance in resolving my problem:

I use comboboxes to select/change data in Grid and Datagrid cells. I could successfully implement this approach with versions prior to However, I have been struggling to achieve the same result with the new version. To demonstrate my problem, I modified the BookLibrary sample by adding another column to the Book datagrid (named it LendTo2) and a row to the Book grid.

The changes I have made are as follows:

All versions:

1) Add the following property to BookListViewModel and BookViewMode:
    private ObservableCollection<Person> personList;
        public ObservableCollection<Person> PersonList
            get { return personList; }
            set { personList = value; }
2) Add the following lines to Initialize() section of BookController:
    bookListViewModel.PersonList = new ObservableCollection<Person>(entityService.Persons);
        bookViewModel.PersonList = new ObservableCollection<Person>(entityService.Persons);
3) Add the following DataGridTemplateColumn to BookListView.xaml:
<DataGridTemplateColumn Header="LendTo2"
    CanUserSort="True" SortMemberPath="Book.LendTo.Firstname">
            <TextBlock Text="{Binding Path=Book.LendTo.Firstname, Mode=OneWay}" Margin="4,0,4,0" />
        </DataTemplate >
    </DataGridTemplateColumn.CellTemplate >
            <ComboBox Margin="0" 
                ItemsSource="{Binding DataContext.PersonList, 
                    RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGrid}}, UpdateSourceTrigger=PropertyChanged}"
                SelectedValue="{Binding Path=Book.PersonId, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=True}"
                SelectedValuePath="Id" DisplayMemberPath="Firstname" />
4) Modify the DataGridSelectionChanged event handler in code behind BookListView.xaml to:
private void DataGridSelectionChanged(object sender, SelectionChangedEventArgs e)
    if (e.Source == e.OriginalSource)
        foreach (BookDataModel book in e.RemovedItems)
        foreach (BookDataModel book in e.AddedItems)
5) Add the following ComboBox to BookView.xaml:
<Label Content="LendTo2" Grid.Column="0" Grid.Row="8"/>
<ComboBox Grid.Column="1" Grid.Row="8" Grid.ColumnSpan="2" Margin="5,11,0,0" x:Name="xPayeeCBox" 
        ItemsSource="{Binding DataContext.PersonList, 
        RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}"
    SelectedValue="{Binding Book.PersonId, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=True}"
    SelectedValuePath="Id" DisplayMemberPath="Firstname" 
Additionally, I made the following changes to the new version (

6) Add the following property to the Book class:
private Guid? personId;
public Guid? PersonId
    get { return personId; }
    set { SetPropertyAndValidate(ref personId, value); }
7) Add the following property to the BookMapping class (but not sure if it is necessary):
this.Property(t => t.PersonId).HasColumnName("PersonId");
8) Remove the following optional navigation property from the BookMapping class:
this.HasOptional(t => t.LendTo).WithMany().Map(t => t.MapKey("PersonId"));
9) Add the following optional navigation property to the BookMapping class:
this.HasOptional(t => t.LendTo).WithMany().HasForeignKey(t => t.PersonId);
As mentioned above, this worked well for previous versions but only partly for the new version in that:

1) When I run the application, all data are displayed correctly, including those in LendTo2 column.

2) When I make changes to a LendTo cell, they are also reflected to LendTo2 cells but not to the corresponding grid cell of BookView.

3) When I click on a cell of the LendTo2 column and select a person, no changes is made to the cell but the background data gets modified because the corresponding grid of the BookView displays the new data.

4) However, if I replace the following line in BookListView.xaml
<TextBlock Text="{Binding Path=Book.LendTo.Firstname, Mode=OneWay}" Margin="4,0,4,0" />
<TextBlock Text="{Binding Path=Book.PersonId, Mode=OneWay}" Margin="4,0,4,0" />
the drop-down menu works and the correct PersonId is displayed.

So, it seems a property change notification of Book.LentTo is missing somewhere.

Thanks again in advance for your reply.