我将下面的listbox控件放在一个网格中,但该列表框不能正确地水平滚动。如果你将滚动条拖到它上面,它就可以正常工作,但如果你点击箭头,它只会滚动到一半。我该如何纠正这种行为呢?
<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>谢谢
发布于 2012-08-05 14:53:32
在我看来像是WinRT中的一个bug。您仍然可以单击HorizontalLargeIncrease RepeatButton,这样就可以正常工作。也许您可以编辑ListBox/ScrollViewer/ScrollBar/HorizontalLargeIncrease RepeatButton的模板,以扩展其点击/触摸目标,使其与HorizontalSmallIncrease RepeatButton的区域重叠,因此,无论您在哪里单击,它都将完全滚动。
或者,您可以将ListBox.ItemsPanel/ItemsPanelTemplate设置为StackPanel。请注意,缺省值是一个VirtualizingStackPanel,这对于长列表更好,因为它不会生成绑定集合中的所有项,而不是StackPanel,但似乎您看到的问题是VirtualizingStackPanel。
https://stackoverflow.com/questions/11808529
复制相似问题