简体   繁体   English

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

[英]Hiding Panorama Title in landscape mode [wp7]

I want to hide the title <controls:Panorama Title="myTitle" Style="{StaticResource customStyle}"> in landscape mode 我想在横向模式中隐藏标题<controls:Panorama Title="myTitle" Style="{StaticResource customStyle}">

I have applied custom style for it (code below) and trying to do this (based on name in custom style) , but I get error the name TitleLayer does not exists in current context: 我已经为它应用了自定义样式(下面的代码)并尝试这样做(基于自定义样式中的名称) ,但是我得到错误名称TitleLayer在当前上下文中不存在:

if ((e.Orientation == PageOrientation.LandscapeRight) || (e.Orientation == PageOrientation.LandscapeLeft))
{
    TitleLayer.Visibility = Visibility.Collapsed;
}

///////////////// Extra Code for lookup /////////////////////// /////////////////用于查找的额外代码/////////////////////////

For this I have applied a custom style: 为此,我应用了自定义样式:

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

Here is how you can hide the Title in Panorama: 以下是如何在全景中隐藏标题:

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

However, I would recommend reading up on the WP7 design guidelines. 但是,我建议阅读WP7设计指南。 It seems like you are using the Panorama in ways it is not intended to be used. 似乎您正在以不希望使用的方式使用Panorama。 Panoramas are intended as portrait only. 全景图仅供参考。 Typically apps should not have many text input fields on Panoramas, hence it should be OK not to support landscape for slideout keyboards. 通常,应用程序在Panoramas上应该没有太多的文本输入字段,因此应该可以不支持滑出式键盘的横向模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM