Windows phone 8:具有不同Z索引的三个ListBox控件,当滚动顶部一个时,就会出现性能问题。为什么?

时间:2014-03-19 02:53:25

标签: windows-phone-8 windows-phone

这是我的演示代码:

<Grid x:Name="LayoutRoot" Background="White">

    <Canvas Name="canvas1" ZIndex="3">
        <ListBox Name="listbox1" Background="White" ItemTemplate="{StaticResource DT}" Height="1000" Width="480">
        </ListBox>
        <Canvas Name="subCanvas1" Visibility="Collapsed">
            <TextBlock Text="No Content!"></TextBlock>
        </Canvas>
    </Canvas>

    <Canvas Name="canvas2" ZIndex="2" >
        <ListBox Name="listbox2" Background="White"  Height="1000" Width="480" ItemTemplate="{StaticResource DT}">
        </ListBox>
        <Canvas Name="subCanvas2" Visibility="Collapsed">
            <TextBlock Text="No Content!"></TextBlock>
        </Canvas>
    </Canvas>

    <Canvas Name="canvas3" ZIndex="1" >
        <ListBox Name="listbox3" Background="White"  Height="1000" Width="480" ItemTemplate="{StaticResource DT}">
        </ListBox>
        <Canvas Name="subCanvas3" Visibility="Collapsed">
            <TextBlock Text="No Content!"></TextBlock>
        </Canvas>
    </Canvas>

</Grid>

,数据模板为:

<DataTemplate x:Key="DT">
        <Grid Margin="0,0,0,10" Background="Transparent">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="6"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="14"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="20"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="20"/>
            </Grid.ColumnDefinitions>
            <TextBlock Text="{Binding Subject}" Grid.Column="1" Grid.ColumnSpan="3" FontSize="26" Foreground="Black" TextTrimming="WordEllipsis" />

            <Grid Grid.Row="2" Grid.Column="1" Margin="2,0,0,0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Border Background="#A99E8A" BorderThickness="1" BorderBrush="#A99E8A" Grid.ColumnSpan="4" MinWidth="60" Padding="4,0,4,2">
                    <TextBlock Foreground="White" FontSize="22" HorizontalAlignment="Center">
                        <TextBlock.Inlines>
                            <Run Text="{Binding Replies}"/>
                        </TextBlock.Inlines>
                    </TextBlock>
                </Border>
                <Polygon Points="4,0 0,8 20,0" Grid.Row="1" Fill="#A99E8A" HorizontalAlignment="Center"></Polygon>
            </Grid>

            <TextBlock Text="{Binding Author}" Grid.Row="2" Grid.Column="2" Foreground="#999999" FontSize="24" HorizontalAlignment="Left" TextTrimming="WordEllipsis" Margin="16,0,2,0"/>
            <TextBlock Text="{Binding DbDateLine}" Grid.Row="2" Grid.Column="3" Foreground="#999999" FontSize="24" HorizontalAlignment="Right"/>

            <Line Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="3" X1="0" X2="480" Stretch="Fill" Stroke="#999999" VerticalAlignment="Bottom" Opacity="0.6"/>
        </Grid>
    </DataTemplate>

后面的代码是:

public List<DemoData> DataSource = new List<DemoData>(); 

    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        DataSource.Add(new DemoData() { Author = "aaa",DbDateLine = "2014-3-3",Replies = "50",Subject = "bbbbb"});
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-3", Replies = "510", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-4", Replies = "520", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-5", Replies = "520", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-6", Replies = "530", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-7", Replies = "540", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-8", Replies = "550", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-9", Replies = "560", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-10", Replies = "570", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-13", Replies = "570", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-23", Replies = "570", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-33", Replies = "570", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-43", Replies = "570", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-53", Replies = "50", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-63", Replies = "570", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-73", Replies = "50", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-83", Replies = "50", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-93", Replies = "50", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-31", Replies = "50", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-32", Replies = "50", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-33", Replies = "50", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-34", Replies = "50", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-35", Replies = "50", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-36", Replies = "50", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-37", Replies = "50", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-38", Replies = "50", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-39", Replies = "50", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-40", Replies = "50", Subject = "bbbbb" });
        DataSource.Add(new DemoData() { Author = "aaa", DbDateLine = "2014-3-312", Replies = "50", Subject = "bbbbb" });

        this.listbox1.ItemsSource = DataSource;
        this.listbox2.ItemsSource = DataSource;
        this.listbox3.ItemsSource = DataSource;
    }

当我滑动顶部列表框(名为“listbox1”)时,它滚动效果不佳,并且滚动不顺畅。

此问题在800 * 480分辨率下不存在。

任何人都可以告诉我是什么原因引起了这个问题吗?

0 个答案:

没有答案