Xaml 轴项目不垂直滚动

Xaml 轴项目不垂直滚动,xaml,windows-phone-8,Xaml,Windows Phone 8,我有一个pivot控件,它将与一些数据绑定: [编辑] 这是我的完整xaml,我尝试放置Grid.Row定义,但仍然无法工作 <phone:PhoneApplicationPage x:Class="Horoscopo.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http

我有一个pivot控件,它将与一些数据绑定:

[编辑] 这是我的完整xaml,我尝试放置Grid.Row定义,但仍然无法工作

<phone:PhoneApplicationPage x:Class="Horoscopo.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">

<!--Data context is set to sample data above and LayoutRoot contains the root grid where all other page content is placed-->
<Grid x:Name="LayoutRoot">
    <Grid.Background>
        <ImageBrush Stretch="None"
                    ImageSource="/Assets/bg.jpg"
                    AlignmentY="Top"
                    AlignmentX="Center" />
    </Grid.Background>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>

    <phone:Pivot>
        <phone:Pivot.Title>
            <TextBlock Text="virgo"
                       Style="{StaticResource PhoneTextNormalStyle}"
                       Foreground="White"></TextBlock>    
        </phone:Pivot.Title>
        <phone:PivotItem >
                        <phone:PivotItem.Header>
                <TextBlock Text="hoje"
                           Margin="9,-7,0,0"
                           Style="{StaticResource PhoneTextTitle1Style}">
                    <TextBlock.Foreground>
                        <LinearGradientBrush EndPoint="0.5,1"
                                             StartPoint="0.5,0">
                            <GradientStop Color="Black"
                                          Offset="0" />
                            <GradientStop Color="#FFE9FF0B"
                                          Offset="1" />
                        </LinearGradientBrush>
                    </TextBlock.Foreground>
                </TextBlock>
            </phone:PivotItem.Header>

            <!--ContentPanel contains LongListSelector and LongListSelector ItemTemplate. Place additional content here-->
            <ScrollViewer Grid.Row="1"
                          Margin="12,0,12,0">
                <Grid x:Name="ContentPanel">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <phone:LongListSelector x:Name="MainLongListSelector"
                                            Margin="0,0,-12,0"
                                            ItemsSource="{Binding Items}"
                                            SelectionChanged="MainLongListSelector_SelectionChanged">
                        <phone:LongListSelector.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Margin="0,0,0,17">
                                    <TextBlock Text="{Binding LineOne}"
                                               TextWrapping="Wrap"
                                               Style="{StaticResource PhoneTextExtraLargeStyle}">
                                        <TextBlock.Foreground>
                                            <LinearGradientBrush EndPoint="0.5,1"
                                                                 StartPoint="0.5,0">
                                                <GradientStop Color="Black"
                                                              Offset="0" />
                                                <GradientStop Color="#FFE9FF0B"
                                                              Offset="1" />
                                            </LinearGradientBrush>
                                        </TextBlock.Foreground>
                                    </TextBlock>
                                    <TextBlock x:Name="txtTexto"
                                               Text="{Binding LineTwo}"
                                               TextWrapping="Wrap"
                                               Margin="12,-6,12,0"
                                               Style="{StaticResource PhoneTextSubtleStyle}"
                                               Foreground="White" />
                                </StackPanel>
                            </DataTemplate>
                        </phone:LongListSelector.ItemTemplate>
                    </phone:LongListSelector>
                </Grid>
            </ScrollViewer>
        </phone:PivotItem>
        <phone:PivotItem>
              <phone:PivotItem.Header>
                <TextBlock Text="favorito"
                           Margin="9,-7,0,0"
                           Style="{StaticResource PhoneTextTitle1Style}">
                    <TextBlock.Foreground>
                        <LinearGradientBrush EndPoint="0.5,1"
                                             StartPoint="0.5,0">
                            <GradientStop Color="Black"
                                          Offset="0" />
                            <GradientStop Color="#FFE9FF0B"
                                          Offset="1" />
                        </LinearGradientBrush>
                    </TextBlock.Foreground>
                </TextBlock>
            </phone:PivotItem.Header>

            <!--ContentPanel contains LongListSelector and LongListSelector ItemTemplate. Place additional content here-->
            <ScrollViewer Grid.Row="1"
                          Margin="12,0,12,0">
                <Grid x:Name="ContentFavoritoPanel">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <phone:LongListSelector x:Name="FavoritoListSelector"
                                            Margin="0,0,-12,0"
                                            ItemsSource="{Binding Favoritos}"
                                            SelectionChanged="MainLongListSelector_SelectionChanged">
                        <phone:LongListSelector.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Margin="0,0,0,17">
                                    <TextBlock Text="{Binding LineOne}"
                                               TextWrapping="Wrap"
                                               Style="{StaticResource PhoneTextExtraLargeStyle}">
                                        <TextBlock.Foreground>
                                            <LinearGradientBrush EndPoint="0.5,1"
                                                                 StartPoint="0.5,0">
                                                <GradientStop Color="Black"
                                                              Offset="0" />
                                                <GradientStop Color="#FFE9FF0B"
                                                              Offset="1" />
                                            </LinearGradientBrush>
                                        </TextBlock.Foreground>
                                    </TextBlock>
                                    <TextBlock x:Name="txtTexto"
                                               Text="{Binding LineTwo}"
                                               TextWrapping="Wrap"
                                               Margin="12,-6,12,0"
                                               Style="{StaticResource PhoneTextSubtleStyle}"
                                               Foreground="White" />
                                </StackPanel>
                            </DataTemplate>
                        </phone:LongListSelector.ItemTemplate>
                    </phone:LongListSelector>
                </Grid>
            </ScrollViewer>
        </phone:PivotItem>



    </phone:Pivot>


</Grid>

但是scrollviewer不工作,我不知道为什么会发生这种情况

我试过这个建议,但没有用。 有人能帮我吗


谢谢。

尝试在网格内容面板下添加以下代码:

<Grid.RowDefinitions>
    <RowDefinition Height="*"/>
</Grid.RowDefinitions>

事实上,正如我所测试的,您的代码运行良好


如果您需要进一步的帮助,您可能需要粘贴整个xaml。

我在数据透视项中使用ScrollViewer时遇到了类似的问题。问题在于ScrollViewer中的内容(网格)与数据透视项的高度相同,因此ScrollViewer实际上无法滚动任何内容。我通过使数据透视项的高度小于ScrollViewer中内容的高度来修复此问题。

此问题是由于使用了多个ScrollViewer;当LongListSelector中的项超过控件的大小时,它具有默认的滚动机制,因此我们不需要在LongListSelector上显式放置ScrollViewer

在您的情况下,将有两个ScrollViewer,一个来自LongListSelector,另一个是显式放置的。所以滚动没有发生

因此,只需从所有透视项中删除ScrollViewer,并将Grid.Row属性设置为LongListSelector