簡體   English   中英

在橫向模式下隱藏全景圖標題[wp7]

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

我想在橫向模式中隱藏標題<controls:Panorama Title="myTitle" Style="{StaticResource customStyle}">

我已經為它應用了自定義樣式(下面的代碼)並嘗試這樣做(基於自定義樣式中的名稱) ,但是我得到錯誤名稱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設計指南。 似乎您正在以不希望使用的方式使用Panorama。 全景圖僅供參考。 通常,應用程序在Panoramas上應該沒有太多的文本輸入字段,因此應該可以不支持滑出式鍵盤的橫向模式。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM