Question

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?

Was it helpful?

Solution

See Bea Stollnitz's excellent article about this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top