在Windows Phone 8应用程序中将网格放置在网格下

时间:2014-06-06 01:39:47

标签: c# windows-phone-8


我正在创建一个Windows Phone 8应用程序。该应用程序有一个支点。要求是在枢轴顶部有一个静态块,以显示需要始终存在的数据,而不管当前哪个枢轴可见。它的一个例子是AccuWeather应用程序。
我尝试过放置一个stackpanel,listview,textbox等,但是两个控制覆盖在同一个网格下,但它不起作用。
另外,我尝试在网格顶部放置另一个网格保持枢轴,在这种情况下页面停止显示。
有关如何解决问题的任何指示/帮助?
我搜索过网络但无法找到适当的信息。

1 个答案:

答案 0 :(得分:0)

试试这个:

[<phone:PhoneApplicationPage
    x:Class="SampleStackPivotApp.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DataContext="{d:DesignData SampleData/MainViewModelSampleData.xaml}"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--Static Control Block-->
        <Grid x:Name="StaticContentGrid" Margin="12,0,12,0">
            <StackPanel>
                <TextBlock Text="Some Content goes Here" FontSize="30"></TextBlock>
                <TextBlock Text="Another Content goes Here" ></TextBlock>
            </StackPanel>
        </Grid>


        <!--Pivot Control-->
        <phone:Pivot Grid.Row="1">
            <phone:Pivot.Title>
                    <StackPanel>
                        <TextBlock Text="Pivot Name Goes here"></TextBlock>
                    </StackPanel>
            </phone:Pivot.Title>
            <!--Pivot item one-->
            <phone:PivotItem Header="first">
                <!--Double line list with text wrapping-->
                <phone:LongListSelector Margin="0,0,-12,0" ItemsSource="{Binding Items}">
                    <phone:LongListSelector.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Margin="0,0,0,17">
                                <TextBlock Text="{Binding LineOne}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
                                <TextBlock Text="{Binding LineTwo}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
                            </StackPanel>
                        </DataTemplate>
                    </phone:LongListSelector.ItemTemplate>
                </phone:LongListSelector>
            </phone:PivotItem>

            <!--Pivot item two-->
            <phone:PivotItem Header="second">
                <!--Double line list no text wrapping-->
                <phone:LongListSelector Margin="0,0,-12,0" ItemsSource="{Binding Items}">
                    <phone:LongListSelector.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Margin="0,0,0,17">
                                    <TextBlock Text="{Binding LineOne}" TextWrapping="NoWrap" Margin="12,0,0,0" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
                                    <TextBlock Text="{Binding LineThree}" TextWrapping="NoWrap" Margin="12,-6,0,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
                                </StackPanel>
                            </DataTemplate>
                    </phone:LongListSelector.ItemTemplate>
                </phone:LongListSelector>
            </phone:PivotItem>
        </phone:Pivot>
    </Grid>
</phone:PhoneApplicationPage>][1]