0

我想摆脱那个全景标题,因为我不喜欢它。我正在尝试通过混合来编辑它的样式,但现在当我在全景图中来回滑动时,它就死了

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

使用 Windows 7 模拟器。

编辑

现在隐藏它。

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

1 回答 1

1

它正在崩溃,因为它需要控制在那里。当您更改 PanoramaItem 时,它会尝试使用,TitleLayer但它为空,因此会引发异常。

无需移除 PanningTitleLayer 控件,只需将其可见性设置为 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"/>
于 2013-10-29T23:05:56.373 回答