Dynamic ViewModel Binding Delay

Mar 15, 2012 at 7:36 PM

I have NoteListView<NoteListViewModel> UserControl that contains an ItemsControl that uses a NoteView<NoteViewModel> UserControl as its DataTemplate.

<ItemsControl ItemsSource={Binding Path=Notes}>
     <ItemsControl.ItemTemplate>
        <DataTemplate>
            <StackPanel>
                <Views:NoteView DataContext={Binding}/>
            </StackPanel>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

The Notes property is a PagedCollectionView of NoteModel.  The NoteListView exists on a TabItem of a DataWindow.  Nothing controversial so far.

The problem/behavior I see is that when the TabItem containing the NoteListView is selected, the entire list first populates using the raw NoteModel object as the DataContext of each NoteView.  Then the DataContexts are swapped with dynamically created NoteViewModel objects.  Since the view model contains additional properties that affect the display of the views, and those properties are not defined on the model objects, this causes a very visible and noticable "flicker" as the entire list updates from the wrong appearance to the correct one.

Is there a solution to this?

Coordinator
Mar 15, 2012 at 7:48 PM

The issue is that WPF and SL don't allow us the set the DataContext before the control is actually loaded (very buggy, but they don't seem to fix this). If you have a repro situation, please create an issue here so we can investigate the issue.

Mar 16, 2012 at 5:32 PM

It sounds like you're already aware of the issue.

Coordinator
Mar 21, 2012 at 12:41 PM

FYI: We have fixed this issue for 3.1

Mar 21, 2012 at 1:22 PM

That's great news!  At this rate, I'm going to owe you a gift basket for all your help.  Thank you.