我有这个枢轴控件,它将与一些数据绑定:
[编辑] 这是我的完整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>
但是滚动浏览器不起作用,我不知道为什么会发生这种情况。
我尝试了这个Thread的建议,但它没有用。 有人可以帮帮我吗?
感谢。
答案 0 :(得分:2)
尝试在Grid ContentPanel下添加以下代码:
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
实际上,您的代码在我测试时运行良好。
如果您需要进一步的帮助,可能需要粘贴整个xaml。
答案 1 :(得分:1)
我在PivotItem中有一个与ScrollViewer类似的问题。问题是ScrollViewer中的内容(网格)与PivotItem的高度相同,因此ScrollViewer实际上没有任何内容可以滚动。我通过使PivotItem高度小于ScrollViewer内容的高度来解决问题。
答案 2 :(得分:0)
问题是由于使用了多个ScrollViewer;当LongListSelector中的项超过控件的大小时,它具有默认的滚动机制,因此我们不需要在LongListSelector上显式地放置ScrollViewer。
在您的情况下,将有两个滚动查看器,一个来自LongListSelector,另一个是您明确放置的。所以滚动没有发生。
因此,只需从所有数据透视表项中删除ScrollViewer,并将Grid.Row属性设置为LongListSelector。