Slow page loading when using ExpanderView & Binding (Windows Phone 7)

I have a Panorama control that has an ExpanderView element (from the Silverlight toolbox). My client wants this page to be customized. That's why I created 3 levels of binding: PanoramaItems, ExpanderView headers, and ExpanderView content. The problem is when I install the itemssource of the Panorama control. It takes about 5 seconds to display items.

Any idea how I can solve this?

C # code:

private void panorama_Loaded(object sender, RoutedEventArgs e)
{
        this.DataContext = App.Products; 
}

XAML Code:

<controls:Panorama Loaded="panorama_Loaded" x:Name="panorama" ItemsSource="{Binding}">
        <controls:Panorama.ItemTemplate>
            <DataTemplate>
                <ListBox  ItemsSource="{Binding Sub_Products}" >
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <toolkit:ExpanderView  Header="{Binding}" Expander="{Binding}" ItemsSource="{Binding Sub_Sub_Products}">
                                <toolkit:ExpanderView.ExpanderTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <Image VerticalAlignment="Center" Source="Images/List.png" Width="25" />
                                            <TextBlock Text="{Binding Title}" />
                                        </StackPanel>
                                    </DataTemplate>
                                </toolkit:ExpanderView.ExpanderTemplate>
                                <toolkit:ExpanderView.ItemTemplate>
                                    <DataTemplate>
                                        <Grid Margin="-30,0,0,0" Background="White"  Width="450" Tap="Grid_Tap" >
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="Auto" />
                                                <ColumnDefinition Width="*" />
                                            </Grid.ColumnDefinitions>
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="Auto" />
                                                <RowDefinition Height="*" />
                                            </Grid.RowDefinitions>
                                            <Image Grid.Row="0"  Source="{Binding ImageSource}" />
                                            <StackPanel  VerticalAlignment="Top" Grid.Column="1">
                                                <TextBlock Text="{Binding Title}"  />
                                                <TextBlock Text="{Binding Description}"  />
                                                <Grid>
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition Width="Auto" />
                                                        <ColumnDefinition Width="*" />
                                                    </Grid.ColumnDefinitions>
                                                    </Grid>
                                                <TextBlock Margin="0,12,32,0" Grid.Row="1" Text="Learn more" />
                                            </StackPanel>
                                        </Grid>
                                    </DataTemplate>
                                </toolkit:ExpanderView.ItemTemplate>
                            </toolkit:ExpanderView>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </DataTemplate>
        </controls:Panorama.ItemTemplate>
    </controls:Panorama>
+3
source share
2 answers

, , . .

Visual Studio. , ( 5 ). , .

+1

ExpanderView ItemsSource xaml , manupulated . ItemsSource="{Binding}". , .

. , Product App.Products. , xaml .

 private void ExpanderView_ManipulationStarted(object sender, System.Windows.Input.ManipulationStartedEventArgs e)
        {
            var expander = sender as ExpanderView;
            expander.ItemsSource = (expander.DataContext as Product).Sub_Sub_Products;
        }

, .

0

All Articles