0

I want to get rid of that Panorama Title as I don't like it all. I am trying to edit it's style through blend which I was able to do but now when I swipe back and forth in the panorama it dies

<controls:Panorama Height="600" Margin="0,0,180,-149" Title="panorama" Width="300" Style="{StaticResource CustomPanoramaStyleTemplate}">
            <controls:PanoramaItem Header="item1">
                <Grid/>
            </controls:PanoramaItem>
            <controls:PanoramaItem Header="item2">
                <Grid/>
            </controls:PanoramaItem>
        </controls:Panorama>


<phone:PhoneApplicationPage.Resources>
    <Style x:Key="CustomPanoramaStyleTemplate" TargetType="controls:Panorama">
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <controlsPrimitives:PanoramaPanel x:Name="panel"/>
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:Panorama">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <controlsPrimitives:PanningBackgroundLayer x:Name="BackgroundLayer" HorizontalAlignment="Left" Grid.RowSpan="2">
                            <Border x:Name="background" Background="{TemplateBinding Background}" CacheMode="BitmapCache"/>
                        </controlsPrimitives:PanningBackgroundLayer>
                        <controlsPrimitives:PanningLayer x:Name="ItemsLayer" HorizontalAlignment="Left" Grid.Row="1">
                            <ItemsPresenter x:Name="items"/>
                        </controlsPrimitives:PanningLayer>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


_exception = {"NullReferenceException"}


   at Microsoft.Phone.Controls.Panorama.WrapAround(Int32 direction)
   at Microsoft.Phone.Controls.Panorama.ProcessFlick()
   at Microsoft.Phone.Controls.Panorama.GestureEnd()
   at Microsoft.Phone.Controls.Panorama.<.ctor>b__3(Object sender, EventArgs args)
   at Microsoft.Phone.Controls.SafeRaise.Raise[T](EventHandler`1 eventToRaise, Object sender, EventArgs args)
   at Microsoft.Phone.Gestures.GestureHelper.RaiseGestureEnd(EventArgs args)
   at Microsoft.Phone.Gestures.GestureHelper.NotifyUp(InputCompletedArgs args)
   at Microsoft.Phone.Gestures.ManipulationGestureHelper.Target_ManipulationCompleted(Object sender, ManipulationCompletedEventArgs e)
   at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)

Using Windows 7 Emulator.

Edit

hiding it now.

<phone:PhoneApplicationPage.Resources>
    <Style x:Key="PanoramaStyleTemplate" TargetType="controls:Panorama">
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <controlsPrimitives:PanoramaPanel x:Name="panel"/>
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:Panorama">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <controlsPrimitives:PanningBackgroundLayer x:Name="BackgroundLayer" HorizontalAlignment="Left" Grid.RowSpan="2">
                            <Border x:Name="background" Background="{TemplateBinding Background}" CacheMode="BitmapCache"/>
                        </controlsPrimitives:PanningBackgroundLayer>
                        <controlsPrimitives:PanningTitleLayer x:Name="TitleLayer" CacheMode="BitmapCache" ContentTemplate="{TemplateBinding TitleTemplate}" Content="{TemplateBinding Title}" FontSize="187" FontFamily="{StaticResource PhoneFontFamilyLight}" HorizontalAlignment="Left" Margin="10,-76,0,9" Grid.Row="0" Visibility="Collapsed"/>
                        <controlsPrimitives:PanningLayer x:Name="ItemsLayer" HorizontalAlignment="Left" Grid.Row="1">
                            <ItemsPresenter x:Name="items"/>
                        </controlsPrimitives:PanningLayer>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</phone:PhoneApplicationPage.Resources>

1 Answer 1

1

It is crashing because it requires that control to be there. When you change the PanoramaItem it attempts to work with the TitleLayer but it is null, so it throws an exception.

Instead of removing the PanningTitleLayer control, just set it's visibility to Collapsed.

<Primitives:PanningTitleLayer x:Name="TitleLayer" CharacterSpacing="-35" 
    ContentTemplate="{TemplateBinding TitleTemplate}" Content="{TemplateBinding Title}"
    FontSize="170" FontFamily="{StaticResource PhoneFontFamilyLight}" 
    HorizontalAlignment="Left" Margin="10,-34,0,0" Grid.Row="0" 
    Visibility="Collapsed"/>
2
  • Hmm, how did you tell that it is required? I changed it to collapsed but still seems to be buggy not sure if it is the emulator(though I am now a different computer). If I got back and for between the 2 states it eventually crashes with the same error. But can't make it crash when I don't do my editing.
    – chobo2
    Oct 30, 2013 at 18:03
  • Aside from the NullReferenceException? Generally elements with names defined in a xaml template are required. They are given names because the code for the control wants to interact with it. I created the default "Windows Phone Panorama App" create a copy of the style and only changed the Visibility of the title. I then tested on the WVGA 512 emulator, panned back and forth and looped the Pano quite a bit of times. No errors were given. Oct 30, 2013 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.