Monday, August 25, 2014

Listview fails to display text of list items when item count exceeds 400 items

I can get a large amount of items to display within a Listview.


However, when I apply a DataTemplate, the listsview does not display any items.


This works:



<ListView x:Name="ContactList" ItemsSource="{Binding SelectedCategory.Contacts}"
Height="425"
Width="425"
Margin="58,175,0,0" Canvas.ZIndex="99"
Background="Transparent" Foreground="#FF333747"
VerticalAlignment="Top" HorizontalAlignment="Left">

<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>

<ItemsControl.Template>
<ControlTemplate TargetType="ItemsControl">
<Border>
<ScrollViewer>
<ItemsPresenter/>
</ScrollViewer>
</Border>
</ControlTemplate>
</ItemsControl.Template>

<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="Hello Wworld" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ListView>


This doesn't:



<ListView x:Name="ContactList" ItemsSource="{Binding SelectedCategory.Contacts}"
Height="425"
Width="425"
Margin="58,175,0,0" Canvas.ZIndex="99"
Background="Transparent" Foreground="#FF333747"
VerticalAlignment="Top" HorizontalAlignment="Left">

<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>

<ItemsControl.Template>
<ControlTemplate TargetType="ItemsControl">
<Border>
<ScrollViewer>
<ItemsPresenter/>
</ScrollViewer>
</Border>
</ControlTemplate>
</ItemsControl.Template>

<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding DisplayName}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ListView>


It appears that displaying listview items using a data template fails once a binding is applied. How can I resolve this?


No comments:

Post a Comment