0

我将以下列表框控件放置在网格内,但列表框无法正确水平滚动。如果您将滚动条拖到它上面可以正常工作,但是如果您单击箭头,它只会滚动到一半。我该如何解决这种行为?

<Page
x:Class="App5.MainPage"
IsTabStop="false"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App5"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
      <ListBox Height="400" Width="200" 
       ScrollViewer.HorizontalScrollBarVisibility="Auto" 
      ScrollViewer.HorizontalScrollMode="Auto">
      <ListBoxItem Content="This is my horizontal test # 1" />
      <ListBoxItem Content="This is my second horizontal test which spams across" />
      </ListBox>
</Grid>
</Page>

谢谢

4

1 回答 1

1

对我来说,这看起来像是 WinRT 中的一个错误。您仍然可以单击 Horizo​​ntalLargeIncrease 重复按钮,这样就可以了。也许您可以编辑 ListBox/ScrollViewer/ScrollBar/Horizo​​ntalLargeIncrease RepeatButton 的模板以扩展其单击/触摸目标以覆盖 Horizo​​ntalSmallIncrease RepeatButton 的区域,因此无论您单击何处 - 它仍会完全滚动。

或者,您可以将 ListBox.ItemsPanel/ItemsPanelTemplate 设置为 StackPanel。请注意,默认值是 VirtualizingStackPanel,它更适合长列表,因为与 StackPanel 相比,它不会生成绑定集合中的所有项目,但您看到的问题似乎与 VirtualizingStackPanel 有关。

于 2012-08-05T06:53:31.520 回答