views:

103

answers:

1

I have this ItemsControl in my View:

<ItemsControl 
    ItemsSource="{Binding ItemPageItemViewModels}"
    ItemTemplate="{StaticResource ItemPageItemViewModelsTemplate}"/>

And above it I have this DataTemplate which renders all the items:

<DataTemplate x:Key="ItemPageItemViewModelsTemplate">
    <TextBlock Text="{Binding Title}"/>
</DataTemplate>

The problem is that although there are 8 objects in the ItemPageItemViewModels ObservableCollection in my ViewModel, only the last object is being displayed on the screen 8 times.

I can set a breakpoint in my ViewModel to see that there are indeed 8 different objects in the ObserverableCollection, but how can I debug the binding to see why this DataTemplate is rendering the last object in the collection 8 times upon my screen?

+3  A: 

See Bea Stollnitz's excellent article about this.

Cameron MacFarland