【问题标题】:What's wrong with Windows Phone 8.1 Pivot? (WinRT - not Silverlight)Windows Phone 8.1 Pivot 有什么问题? (WinRT - 不是 Silverlight)
【发布时间】:2015-09-07 16:28:17
【问题描述】:

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

奇怪的事情正在发生。 简单的 Pivot 视图非常滞后,而且它也不能正确显示视图。 我正在使用最新的 Visual Studio 2015。在我链接的视频中,您可以看到以下 Page 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>

有人能说出这里发生了什么吗?我应该使用来自第 3 方的一些枢轴类似物,还是只是忘记在新操作系统中使用它? 把我的头发拉出来。 任何解决方案将不胜感激!

Link to video

【问题讨论】:

    标签: windows-phone-8 windows-runtime windows-phone-8.1 pivot winrt-xaml


    【解决方案1】:

    问题是您在Pivot 上使用CacheMode="BitmapCache"。去掉这条线,以后性能应该不错了。

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

    滥用 CacheMode 功能会损害性能,因此您需要认真考虑您在做什么。如果您的可视化树交错缓存和未缓存的元素,您实际上会导致在幕后创建多个渲染表面。未缓存的表面在软件中呈现,而缓存的表面在硬件中呈现。如果您可以最大限度地减少渲染表面的总数并让硬件尽其所能地工作,您的性能将是最佳的。

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

    【讨论】:

    • 非常感谢。我还在学习 wp 和 WinRT 框架。然而有趣的是,wp 8.0 上的相同代码使其正常工作
    猜你喜欢
    • 2023-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-03
    • 1970-01-01
    • 1970-01-01
    • 2014-11-21
    相关资源
    最近更新 更多