wp7 复杂页面下去除ListBox虚拟化

最近做个项目,页面设计布局复杂,使用默认 ListBox 由于默认开启了虚拟化,会遇到暴力拖拉加载数据错位等问题,于是就想把虚拟化去除,代码如下

 

View Code
 1                                     <ListBox Name="pleasureListBox">
2 <!-- 去除虚拟化-->
3 <ListBox.ItemsPanel>
4 <ItemsPanelTemplate>
5 <StackPanel>
6 </StackPanel>
7 </ItemsPanelTemplate>
8 </ListBox.ItemsPanel>
9
10 <ListBox.ItemTemplate>
11 <DataTemplate>
12 <StackPanel>
13 <!-- 头部模板-->
14 <Button Style="{StaticResource NoneStyleButtonStyle}">
15 <html:HtmlTextBlock LineHeight="36" Text="{Binding summary}" Foreground="#444444" TextWrapping="Wrap" FontSize="22" FontFamily="DengXian" MaxWidth="400" />
16 </Button>
17 <!--内容模板 -->
18 <ListBox Name="InfoItemListBox" ItemsSource="{Binding infoItemList}" Style="{StaticResource NotRollingListBoxStyle}">
19 <ListBox.ItemTemplate>
20 <DataTemplate>
21 <StackPanel>
22 <Grid >
23 <Grid HorizontalAlignment="Center">
24 <Image Name="BackgroundImage" Source="/MostInteresting;component/Images/LargerImageLoading1.png" Width="{Binding imgWidth}" MaxWidth="400" Stretch="None" VerticalAlignment="Center"/>
25 <Border BorderBrush="#bbbbbb" BorderThickness="3" Height="{Binding imgHeight}" MaxHeight="2010" MaxWidth="410" >
26 <Image Source="{Binding img}" ImageOpened="PleasureListImage_ImageOpened" DoubleTap="PleasureListImage_DoubleTap" Stretch="Uniform" Margin="5" MaxHeight="2000" MaxWidth="400"/>
27 </Border>
28 </Grid>
29 </Grid>
30 <html:HtmlTextBlock Margin="30,5,0,5" Width="400" Text="{Binding intro}" FontSize="18" Foreground="#999999" TextWrapping="Wrap" FontFamily="DengXian" />
31 </StackPanel>
32 </DataTemplate>
33 </ListBox.ItemTemplate>
34 </ListBox>
35
36 <!--按钮模板 Visibility="Collapsed" -->
37
38 <StackPanel Width="480" Orientation="Horizontal" >
39 <TextBlock Text="{Binding source}" FontSize="12" Foreground="#999999" FontFamily="DengXian" Margin="10,25,0,0" />
40 <TextBlock Text="{Binding lastupdateTime}" FontSize="12" Foreground="#999999" FontFamily="DengXian" Margin="0,25,0,0" Width="80"/>
41 <TextBlock Name="IndexNum" Text="{Binding indexNum}" Visibility="Collapsed" />
42 <TextBlock Name="Pid" Text="{Binding id}" Visibility="Collapsed" />
43 <Button Style="{StaticResource NoneStyleButtonStyle}">
44 <StackPanel Name="Like" Background="#1BA1E2" Orientation="Horizontal" Tap="Like_Tap" Margin="10">
45 <TextBlock Text="喜欢:" FontFamily="DengXian" Margin="12,7,0,5" FontSize="20"/>
46 <TextBlock Name="favNum" Text="{Binding fav}" FontFamily="DengXian" Margin="0,7,12,5" FontSize="20"/>
47 </StackPanel>
48 </Button>
49 <Button Style="{StaticResource NoneStyleButtonStyle}">
50 <StackPanel Name="Favorites" Background="#1BA1E2" Tap="Favorites_Tap" Margin="10">
51 <TextBlock Text="收藏" FontFamily="DengXian" Margin="12,7,12,5" FontSize="20"/>
52 </StackPanel>
53 </Button>
54 <Button Style="{StaticResource NoneStyleButtonStyle}">
55 <StackPanel Name="Share" Background="#1BA1E2" Tap="Share_Tap" Margin="10">
56 <TextBlock Text="分享" FontFamily="DengXian" Margin="12,7,12,5" FontSize="20"/>
57 </StackPanel>
58 </Button>
59 </StackPanel>
60
61 <Image Source="/MostInteresting;component/Images/DottedLine.png" ></Image>
62
63 <Grid Width="410" Height="100" Visibility="{Binding isEnd}">
64 <TextBlock Text="请按下一页" Foreground="#444444"></TextBlock>
65 </Grid>
66
67 </StackPanel>
68 </DataTemplate>
69 </ListBox.ItemTemplate>
70
71 </ListBox>

 

posted @ 2012-03-25 14:59  iiixxxiii  阅读(618)  评论(1编辑  收藏  举报