C#Windows RT列表框水平滚动问题

时间:2012-08-04 12:05:41

标签: c# .net microsoft-metro windows-runtime winrt-xaml

我将以下列表框控件放在网格中,但列表框不能正确水平滚动。如果你拖动它滚动它工作正常,但如果你点击箭头它只滚动一半。我该如何解决这个问题?

<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>

由于

1 个答案:

答案 0 :(得分:1)

看起来像WinRT中的一个错误。你仍然可以点击Horizo​​ntalLargeIncrease RepeatButton,这是有效的。也许您可以编辑ListBox / ScrollViewer / ScrollBar / Horizo​​ntalLargeIncrease RepeatButton的模板以扩展其单击/触摸目标以重叠Horizo​​ntalSmallIncrease RepeatButton的区域,因此无论您在何处单击 - 它仍将完全滚动。

或者,您可以将ListBox.ItemsPanel / ItemsPanelTemplate设置为StackPanel。请注意,默认值为VirtualizingStackPanel,对于长列表更好,因为它不会生成绑定集合中的所有项目而不是StackPanel,但看起来您看到的问题是VirtualizingStackPanel。

相关问题