Reputation: 640
I have this pivot control that will be binded with some data:
[EDIT] Here is my full xaml, i tried to put the Grid.Row definitions and still not working.
<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>
But the scrollviewer dont work, and i dont know why this happens.
I tried the suggestions of this Thread, but it didnt work. Anybody can help me?
Thanks.
Upvotes: 2
Views: 1649
Reputation: 600
The problem is due to usage of multiple ScrollViewer; LongListSelector has default scrolling mechanism when items in it exceeds the size of the control, so we dont need to explicitly put a ScrollViewer over LongListSelector.
In your case, there will be two scrollviewers, one from LongListSelector and one which you put explicitly. So scrolling is not happening.
So, Just remove the ScrollViewer from all of your Pivot Items and set the Grid.Row property to the LongListSelector.
Upvotes: 0
Reputation: 1215
I had a similar issue with a ScrollViewer inside a PivotItem. The problem was that the content (a Grid) inside the ScrollViewer was the same height as the PivotItem so there was effectively nothing for the ScrollViewer to scroll. I fixed the problem by making the PivotItem height smaller than the height of the content inside the ScrollViewer.
Upvotes: 1
Reputation: 504
try to add the code below under your Grid ContentPanel :
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
Actually, your code works fine as I've tested.
If you need further help, you may need to paste your whole xaml.
Upvotes: 2