ListBox VirtualizingStackPanel.VirtualizationMode = "Disposal" does not work in Windows Phone 7.5

I'm having performance issues in the Windows Phone 7.5 application I'm working on. I have a ListBox that uses VirtualizationMode="Recycling" and a DataTemplate . It seems to work fine except for poor performance. By doing some performance profiling, I can see while I am browsing through the list, since it uses 62% of the processor, creating a new instance of the user control that I placed in the DataTemplate . I realized that the whole point of VirtualizationMode="Recycling" was to reuse all the UIElements in the ListBox and not have to create new instances or use the old ones, so I would expect that this is exactly what should not be happening.

Here is the corresponding XAML:

 <ListBox ItemsSource="{Binding EpisodeRows}" toolkit:TiltEffect.SuppressTilt="True" Margin="12,0" VirtualizingStackPanel.VirtualizationMode="Recycling"> <ListBox.ItemTemplate> <DataTemplate> <Grid VerticalAlignment="Top" Height="111" VirtualizingStackPanel.VirtualizationMode="Recycling" > <StackPanel Orientation="Horizontal" Visibility="{Binding TilesVisibility}"> <landerGame:LevelTileUserControl PartText="{Binding PartText_1}" ScoreText="{Binding ScoreText_1}" Star1Visibility="{Binding Star1Vi <landerGame:LevelTileUserControl PartText="{Binding PartText_2}" ScoreText="{Binding ScoreText_2}" Star1Visibility="{Binding Star1Vi <landerGame:LevelTileUserControl PartText="{Binding PartText_3}" ScoreText="{Binding ScoreText_3}" Star1Visibility="{Binding Star1Vi <landerGame:LevelTileUserControl PartText="{Binding PartText_4}" ScoreText="{Binding ScoreText_4}" Star1Visibility="{Binding Star1Vi <landerGame:LevelTileUserControl PartText="{Binding PartText_5}" ScoreText="{Binding ScoreText_5}" Star1Visibility="{Binding Star1Vi <landerGame:LevelTileUserControl PartText="{Binding PartText_6}" ScoreText="{Binding ScoreText_6}" Star1Visibility="{Binding Star1Vi </StackPanel> <TextBlock VerticalAlignment="Top" Text="{Binding EpisodeTitleText}" Style="{StaticResource PhoneTextExtraLargeStyle}" Margin="0,0,0,5" </Grid> </DataTemplate> </ListBox.ItemTemplate> </ListBox> 

Here is a screenshot of my performance profiling results when scrolling through the list: Performance profiling results

Here is what the list looks like (this is the level of choice for the game): Level select

I looked around and picked up any articles on VirtualizationMode="Recycling" that didn't work. Any ideas would be most appreciated at this point.

EDIT: I downloaded the full appropriate code for this project: someone wants to try it for themselves here: http://maketag.net/landerGame.rar

+4
source share
1 answer

It is difficult to test since you did not provide any information about your user controls.

I would suggest ListBox , since the behavior you are trying to emulate is indeed a WrapPanel .

Due to the fact that you add so many user controls to each ListBox , I assume that this leads to performance hit. If you switched to a WrapPanel and then tied to your collection of elements, you are likely to get better performance since each element will be virtualized rather than trying to virtualize six elements at a time (which probably doesn't work).

Edit: Looking through my code, I think there are a few changes you could make to improve performance. First of all, get rid of the ListBox and use the ItemsControl as follows:

 <controls:Pivot Title="LANDER GAME"> <!--Pivot item one--> <controls:PivotItem Header="Episodes"> <ScrollViewer> <ItemsControl ItemsSource="{Binding EpisodeRows}" toolkit:TiltEffect.SuppressTilt="True" Margin="12,0"> <ItemsControl.ItemTemplate> <DataTemplate> <Grid VerticalAlignment="Top" Height="111" > <StackPanel Orientation="Horizontal" Visibility="{Binding TilesVisibility}"> ... </StackPanel> <TextBlock VerticalAlignment="Top" Text="{Binding EpisodeTitleText}" Style="{StaticResource PhoneTextExtraLargeStyle}" Margin="0,0,0,5" Visibility="{Binding TitleVisibility}" /> </Grid> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </ScrollViewer> </controls:PivotItem> 

What I would like to do is get rid of the hard-coded variable types PartText_1 , PartText_2 . Just create a list of items and another ItemsControl inside your other control.

Just getting rid of the ListBox made it smoother. I also removed VirtualizingStackPanel.VirtualizationMode="Recycling" , as it caused a performance hit in the beginning, once it booted up, it seemed smoother.

+1
source

All Articles