简体   繁体   中英

Hiding Panorama Title in landscape mode [wp7]

I want to hide the title <controls:Panorama Title="myTitle" Style="{StaticResource customStyle}"> in landscape mode

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:

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. It seems like you are using the Panorama in ways it is not intended to be used. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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