我试图达到以下效果:可滚动(垂直)的项目列表;如果有这样的需要,每个项目应该可以水平滚动。我尝试了以下代码:
<ScrollViewer x:Name="historyViewer"
VerticalScrollMode="Enabled" VerticalScrollBarVisibility="Hidden"
HorizontalScrollMode="Disabled" HorizontalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding History}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical" HorizontalAlignment="Stretch">
<ScrollViewer VerticalScrollMode="Disabled" VerticalScrollBarVisibility="Hidden"
HorizontalScrollMode="Enabled" HorizontalScrollBarVisibility="Hidden">
<TextBlock Foreground="{ThemeResource PhoneMidBrush}" FontSize="{ThemeResource TextStyleExtraLargeFontSize}" HorizontalAlignment="Left" Text="{Binding Expression}" />
</ScrollViewer>
<ScrollViewer x:Name="resultScroll" VerticalScrollMode="Disabled" VerticalScrollBarVisibility="Hidden"
HorizontalScrollMode="Enabled" HorizontalScrollBarVisibility="Hidden">
<TextBlock FontSize="{ThemeResource TextStyleExtraLargePlusFontSize}" HorizontalAlignment="Right" Text="{Binding Result}" />
</ScrollViewer>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
问题是,如果列表项太宽,它们会扩展主滚动查看器的宽度而不是可滚动 - 即使它的水平对齐设置为拉伸。
我该如何解决?