2013-11-19 2 views
2

У меня есть этот контроль поворота, которая будет переплетена с некоторыми данными:Pivot Пункт не вертикальная прокрутка

[EDIT] Вот мой полный 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 не работают, и я не знаю, почему это происходит.

Я пробовал предложения этого Thread, но он не работал. Кто-нибудь может мне помочь?

Спасибо.

ответ

2

попробуйте добавить код, приведенный ниже под сетки ContentPanel:

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

На самом деле, ваш код работает отлично, как я проверил.

Если вам нужна дополнительная помощь, вам может понадобиться вставить весь xaml.

+0

Он работает для меня – FetFrumos

1

У меня была аналогичная проблема с ScrollViewer внутри PivotItem. Проблема заключалась в том, что содержимое (сетка) внутри ScrollViewer было той же высоты, что и PivotItem, поэтому для прокрутки ScrollViewer фактически ничего не было. Я исправил проблему, сделав высоту PivotItem меньшей, чем высота содержимого внутри ScrollViewer.

+0

Отлично, спасибо, спасли мой день! –

0

Проблема заключается в использовании нескольких ScrollViewer; LongListSelector имеет механизм прокрутки по умолчанию, когда элементы в нем превышают размер элемента управления, поэтому нам не нужно явно помещать ScrollViewer поверх LongListSelector.

В вашем случае будут два прокрутки, один из LongListSelector и тот, который вы явно помещаете. Так что прокрутки не происходит.

Итак, просто снимите ScrollViewer со всех ваших сводных элементов и установите свойство Grid.Row для LongListSelector.

Смежные вопросы