C# 在横向模式下隐藏全景标题[wp7]

C# 在横向模式下隐藏全景标题[wp7],c#,xaml,silverlight,windows-phone-7,C#,Xaml,Silverlight,Windows Phone 7,我想在横向模式下隐藏标题 我已经为它应用了自定义样式(下面的代码),并尝试这样做(基于自定义样式中的名称),但我得到错误名称TitleLayer在当前上下文中不存在: if ((e.Orientation == PageOrientation.LandscapeRight) || (e.Orientation == PageOrientation.LandscapeLeft)) { TitleLayer.Visibility = Visibility.Collapsed; } 用于查找

我想在横向模式下隐藏标题

我已经为它应用了自定义样式(下面的代码),并尝试这样做(基于自定义样式中的名称),但我得到错误名称TitleLayer在当前上下文中不存在:

if ((e.Orientation == PageOrientation.LandscapeRight) || (e.Orientation == PageOrientation.LandscapeLeft))
{
    TitleLayer.Visibility = Visibility.Collapsed;
}
用于查找的额外代码

为此,我应用了自定义样式:

<phone:PhoneApplicationPage.Resources>
        <Style x:Key="customStyle" 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"/>
                            <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>

以下是如何在全景中隐藏标题:

Grid grid = VisualTreeHelper.GetChild(panorama, 0) as Grid;
FrameworkElement titleLayer = grid.FindName("TitleLayer") as FrameworkElement;
titleLayer.Visibility = System.Windows.Visibility.Collapsed;

然而,我建议大家阅读WP7设计指南。似乎您正在以不打算使用的方式使用全景图。全景图仅用作肖像。通常情况下,应用程序在全景图上不应该有很多文本输入字段,因此不支持滑动键盘的横向视图应该是可以的。

全景图控件不打算在横向模式下使用。你想这么做的原因是什么?@Matt Flexibility,虽然我的应用程序最适合纵向,但作为一名开发人员,我也应该尊重带有横向滑动键盘的设备。