0
votes

So I've decided to migrate from Windows Phone 8.0 to Windows Phone 8.1 API - not the silverlight one. The reason was that I wanted to use Win2D drawing library which is not supported for Silverlight 8.1 or WP 8.0

The weird things are happening. Simple Pivot view is incredibly laggy and also it is not displaying views properly. I am using latest Visual Studio 2015. On the video I linked you can see the result of following Page XAML code (just for testing):

<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>

Is anyone able to tell what is going on here? Should I use some pivot analogs from 3rd parties or maybe just forget about using it in new os? Pulling my hair out. Any solution would be hugely appreciated!

Link to video

1

1 Answers

2
votes

The problem is you are using CacheMode="BitmapCache" on your Pivot. Remove this line and the performance should be good after.

First of all the caching is applied to the element and all of it’s child elements and BitmapCaching should be used in scenarios where you are blending, transforming (translating, stretching, rotating). If you need BitmapCaching then try not to use it on root controls, use it on the children that really need BitmapCaching.

Misuse of the CacheMode feature can hurt performance, so you need to really think through what you are doing. If your visual tree is interleaving cached and un-cached elements, you are effectively causing multiple rendering surfaces to get created behind the scenes. The un-cached surfaces are rendered in software and the cached surfaces are rendered in hardware. Your performance will be best if you can minimize the total number of rendering surfaces and get the hardware to do work where it can.

Reference from another StackOverflow answer. I hope it helps.