Frage

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>
War es hilfreich?

Lösung

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"/>
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top