locked
Nested comment UI , running out of memory? (long lists)

    Question

  • Part of my app needs to display reddit comments in a hieracal way , in other words each reply should be slightly to the right of the parent.

    I am using an items control with virtualization , and I have tried both nested comments or just a really long list of comments.

    The memory starts shooting up when settings the ItemsSource and way above the limit.

    Here is some XAML for the comment template and itemspanel.

    <DataTemplate x:Key="commentTemplate">
    			<Border Margin="{Binding Margin}" VerticalAlignment="Top" BorderBrush="#4C68FF00" BorderThickness="1,0,0,0" >
    				<StackPanel>
    					<TextBlock TextWrapping="Wrap" Text="{Binding Username}" VerticalAlignment="Top" Foreground="#FFCBCBCB" Margin="3,0,0,0"/>
    					<TextBlock Text="{Binding Text}" VerticalAlignment="Top" FontSize="13.333" FontFamily="Segoe WP" TextWrapping="Wrap" Padding="0" Margin="3,3,0,0"/>
    					<ItemsControl x:Name="ls" Margin="10,0,0,0" VerticalAlignment="Top" ItemsSource="{Binding Replies}" ItemTemplate="{StaticResource commentTemplate}" >
    						 <ItemsControl.Template>
    							<ControlTemplate TargetType="ItemsControl">
    								<ScrollViewer HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Disabled">
    									<ItemsPresenter />
    								</ScrollViewer>
    							</ControlTemplate>
    						 </ItemsControl.Template>
    
    						 <ItemsControl.ItemsPanel>
    						
    						<ItemsPanelTemplate>
    							<VirtualizingStackPanel VerticalAlignment="Top"/>
    						</ItemsPanelTemplate>
    					</ItemsControl.ItemsPanel>
    					</ItemsControl>
    					
    
    				</StackPanel>
    			</Border>
    		</DataTemplate>
    		<ItemsPanelTemplate x:Key="itemPanelTemplate">
    			<VirtualizingStackPanel VerticalAlignment="Top"/>
    		</ItemsPanelTemplate>
    		

    Basically each comment item template has another list inside it for the replies.

    I've tried getting rid of that and putting everything in a long list but it still crashes.

    No exception , no error.

    Same for trying with a ListView.

    This is a Universal App , is there a better way to do very long lists?

    Saturday, November 1, 2014 1:34 PM

Answers

All replies