views:

449

answers:

2

I have one UserControl which has a ListView showing a list of Client objects. Double clicking one of the rows plays an animation and transitions to another UserControl which shows the list of accounts for that client.

The second user control is bound to the Accounts property on the Client object. The list of accounts is loaded the first time the property is accessed. This all works great if the list of accounts is small. If the list of accounts is large, there is a very noticeable delay between double clicking and the list of accounts appearing. And the animation doesn't play at all.

I understand what's going on here, but I'm not sure of the best way to fix it. How would I make it so that the animation still plays and the second user control is shown, but the list of accounts appears as they're loaded? I understand I'm going to need to load the list view asynchronously, and I have no problem using a BackgroundWorker for this, but I'm not sure where this loading would happen.

The list of accounts is an ObservableCollection, and the Client object implements INotifyPropertyChanged, however doesn't call PropertyChanged for the accounts property because it doesn't have a setter.

+1  A: 

I think you need to look at the Virtualized controls in WPF - these only display the contents required not the whole list and are therefore a lot faster than the standard ListView.

MrTelly
A: 

You can try and set IsAsync=true on the binding, for example: {Binding Path=Accouns, IsAsync=true}

Nir