之間切換當切換到該轉動加載數據項目,從一個項目切換到另一個時,我遇到口吃時刪除「口吃」。我已經將數據加載到一個單獨的線程,這有幫助,但我仍然遇到一些糟糕的表現....想知道如果你們有任何想法....Windows Phone 7的我怎麼樞紐項目
這裏是關鍵項目
<Grid x:Name="LayoutRoot" Background="Transparent">
<!--Pivot control-->
<controls:Pivot Name="panCorals" Title="Corals" Foreground="#01487e"
SelectionChanged="panCorals_SelectionChanged">
<controls:Pivot.Background>
<ImageBrush ImageSource="PivotBackground.png"/>
</controls:Pivot.Background>
<!--Search Corals-->
<controls:PivotItem Header="Search" Foreground="#01487e">
<Grid>
<toolkit:PerformanceProgressBar Name="SearchCoralsProgressBar" HorizontalAlignment="Left"
VerticalAlignment="Top" Width="466"
IsEnabled="{Binding IsSearchLoading}" IsIndeterminate="{Binding IsSearchLoading}" />
<StackPanel>
<TextBox Name="txtSearchTerm" KeyDown="txtSearchTerm_KeyDown" />
<ListBox Name="lbSearchCorals" Margin="0,0,-12,0" ItemsSource="{Binding SearchCorals}"
SelectionChanged="lbSearchCorals_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="0,0,0,17">
<Image Source="{Binding MainImageURI}" Height="100" Width="100" Margin="12,0,9,0" />
<StackPanel Width="311">
<TextBlock Text="{Binding CommonName}" Foreground="#112d42" TextWrapping="NoWrap" Style="{StaticResource PhoneTextTitle2Style}"/>
<TextBlock Text="{Binding ScientificName}" Foreground="#112d42" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</Grid>
</controls:PivotItem>
<!--Top Corals-->
<controls:PivotItem Header="Top" Foreground="#01487e" VerticalAlignment="Top" >
<Grid>
<toolkit:PerformanceProgressBar Name="TopCoralsProgressBar" HorizontalAlignment="Left"
VerticalAlignment="Top" Width="466"
IsEnabled="{Binding IsTopLoading}" IsIndeterminate="{Binding IsTopLoading}" />
<ListBox Name="lbTopCorals" Margin="0,0,-12,0" ItemsSource="{Binding TopCorals}" SelectionChanged="lbTopCorals_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="0,0,0,17">
<Image Source="{Binding MainImageURI}" Height="100" Width="100" Margin="12,0,9,0" />
<StackPanel Width="311">
<TextBlock Text="{Binding CommonName}" Foreground="#112d42" TextWrapping="NoWrap" Style="{StaticResource PhoneTextTitle2Style}"/>
<TextBlock Text="{Binding ScientificName}" Foreground="#112d42" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<StackPanel Margin="10,50,0,0" Orientation="Horizontal">
<TextBlock x:Name="tbProgress"/>
</StackPanel>
</Grid>
</controls:PivotItem>
<!--New Corals-->
<controls:PivotItem Header="New">
<Grid>
<toolkit:PerformanceProgressBar Name="NewCoralsProgressBar" HorizontalAlignment="Left"
VerticalAlignment="Top" Width="466"
IsEnabled="{Binding IsNewLoading}" IsIndeterminate="{Binding IsNewLoading}" />
<ListBox Name="lbNewCorals" Margin="0,0,-12,0" ItemsSource="{Binding NewCorals}" SelectionChanged="lbNewCorals_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="0,0,0,17">
<Image Source="{Binding MainImageURI}" Height="100" Width="100" Margin="12,0,9,0" />
<StackPanel Width="311">
<TextBlock Text="{Binding CommonName}" Foreground="#112d42" TextWrapping="NoWrap" Style="{StaticResource PhoneTextTitle2Style}"/>
<TextBlock Text="{Binding ScientificName}" Foreground="#112d42" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</controls:PivotItem>
</controls:Pivot>
</Grid>
而後面的代碼...
private void panCorals_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
switch (panCorals.SelectedIndex)
{
case 0: //search corals
break;
case 1: //top corals
if (!App.vmCoral.IsTopDataLoaded)
{
App.vmCoral.IsTopLoading = true;
if (App.HasConnectivity)
{
//get corals from web
bw.DoWork += new DoWorkEventHandler(bw_DoWorkTopCoralsWeb);
if (bw.IsBusy != true)
{
bw.RunWorkerAsync();
}
}
else
{
//get saved corals from device
bw.DoWork += new DoWorkEventHandler(bw_DoWorkTopCoralsSaved);
if (bw.IsBusy != true)
{
bw.RunWorkerAsync();
}
}
}
break;
case 2: //new corals
if (!App.vmCoral.IsNewDataLoaded)
{
App.vmCoral.IsNewLoading = true;
if (App.HasConnectivity)
{
//get corals from web
bw.DoWork += new DoWorkEventHandler(bw_DoWorkNewCoralsWeb);
if (bw.IsBusy != true)
{
bw.RunWorkerAsync();
}
}
else
{
//get saved corals from device
bw.DoWork += new DoWorkEventHandler(bw_DoWorkNewCoralsSaved);
if (bw.IsBusy != true)
{
bw.RunWorkerAsync();
}
}
}
break;
default:
break;
}
}
只是想提及LongListSelector的想法,並給你信用。這似乎是真正幫助的事情。 – Jarrette