Windows Phone 8.1 Pivot 有什么问题? (WinRT - 不是 Silverlight)

What's wrong with Windows Phone 8.1 Pivot? (WinRT - not Silverlight)

所以我决定从 Windows Phone 8.0 迁移到 Windows Phone 8.1 API - 而不是 silverlight。 原因是我想使用 Silverlight 8.1 或 WP 8.0 不支持的 Win2D 绘图库

奇怪的事情正在发生。 Simple Pivot 视图非常滞后,而且它不能正确显示视图。 我使用的是最新的 Visual Studio 2015。在我链接的视频中,您可以看到以下页面 XAML 代码(仅用于测试)的结果:

<Page
x:Class="Apptest2.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Apptest2"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <StackPanel Grid.Column="0">
        <Button Content="Go"
               />
    </StackPanel>
    <Pivot Grid.Row="1"
           x:Name="PivotView"
           Margin="10,0,10,15"
           CacheMode="BitmapCache"
           VerticalContentAlignment="Stretch">
        <PivotItem Header="item1">
            <Grid Background="BlueViolet" />
        </PivotItem>
        <PivotItem Header="item2">
            <Grid Background="BlueViolet" />
        </PivotItem>
        <PivotItem Header="item3">
            <Grid Background="BlueViolet" />
        </PivotItem>
        <PivotItem Header="item4">
            <Grid Background="BlueViolet" />
        </PivotItem>
        <PivotItem Header="item5">
            <Grid Background="BlueViolet" />
        </PivotItem>
        <PivotItem Header="item6">
            <Grid Background="BlueViolet" />
        </PivotItem>


    </Pivot>
</Grid>
</Page>

有谁能告诉我这是怎么回事吗?我应该使用来自 3rd 方的一些枢轴类似物还是忘记在新 os 中使用它? 拔我的头发。 任何解决方案将不胜感激!

Link to video

问题是您在 Pivot 上使用 CacheMode="BitmapCache"。去掉这一行,之后性能应该会不错。

首先,缓存应用于元素及其所有子元素,BitmapCaching 应该用于混合、变换(平移、拉伸、旋转)的场景。如果您需要 BitmapCaching,请尽量不要在根控件上使用它,请在真正需要 BitmapCaching 的子控件上使用它。

CacheMode 功能的误用会影响性能,因此您需要认真考虑您的操作。如果您的可视化树交错缓存和未缓存元素,则实际上是在幕后创建多个渲染表面。未缓存的表面在软件中渲染,缓存的表面在硬件中渲染。如果您可以最大限度地减少渲染表面的总数并让硬件尽可能地工作,您的性能将是最好的。

Reference 来自另一个 Whosebug 答案。希望对你有帮助。