Rendering ListBox takes too long on Windows Phone

Posted by Bhawk1990 on Stack Overflow See other posts from Stack Overflow or by Bhawk1990
Published on 2012-11-09T20:26:14Z Indexed on 2012/11/10 5:00 UTC
Read the original article Hit count: 112

Filed under:
|

I am working on a Windows Phone 7 Application using Local SQLite Database and I'm having an issue with the rendering time of pages that use DataBinding.

Currently it takes 60-70ms to retrieve the data from the database. Then it takes about 3100ms to render the data retrieved using a ListBox with DataBinding.

Here you can see the DataTemplate of the ListBox:

<DataTemplate x:Key="ListBoxItemTemplate">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="68" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <TextBlock x:Name="TimeColumn"
                        Text="{Binding TimeSpan}" Grid.Column="0" Grid.Row="0"
                        Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" />
        <TextBlock Text="{Binding Stop.StopName}" Grid.Column="1" Grid.Row="0" 
                                Margin="15,0,0,0" TextWrapping="NoWrap" Foreground="Black"
                                HorizontalAlignment="Left" VerticalAlignment="Center" />
    </Grid>
 </DataTemplate>

Comment: I have tried it using Canvas instead of Grid too, same result.

Then, the database loads data into a CSList (using ViciCoolStorage) and that gets Binded to the ListBox:

StationList.ItemsSource = App.RouteViewModel.RouteStops;

Comment: I have tried to add the elements of the CSList to an ObservableCollection and bind that to the interface but didn't seem to change anything.

Question: Am I doing something wrong that results in a huge load time - even if just loading 10 elements -, or this is normal? Do you have any recommendations to get a better performance with DataBinding?

Thank you for your answers in advance!

© Stack Overflow or respective owner

Related posts about listbox

Related posts about windows-phone