通过混合编辑后全景保持崩溃

时间:2013-10-29 21:19:58

标签: windows-phone-7 expression-blend panorama-control

我想摆脱全景标题,因为我不喜欢这一切。我试图通过混合来编辑它的风格,但是现在当我在全景图中来回扫描时它会消失

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

1 个答案:

答案 0 :(得分:1)

它崩溃了,因为它需要控制在那里。当您更改PanoramaItem时,它会尝试使用TitleLayer,但它为null,因此会抛出异常。

不要删除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"/>