首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >C# Windows RT列表框水平滚动问题

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

Stack Overflow用户
提问于 2012-08-04 20:05:41
回答 1查看 1.4K关注 0票数 0

我将下面的listbox控件放在一个网格中,但该列表框不能正确地水平滚动。如果你将滚动条拖到它上面,它就可以正常工作,但如果你点击箭头,它只会滚动到一半。我该如何纠正这种行为呢?

代码语言:javascript
复制
<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>

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-08-05 14:53:32

在我看来像是WinRT中的一个bug。您仍然可以单击HorizontalLargeIncrease RepeatButton,这样就可以正常工作。也许您可以编辑ListBox/ScrollViewer/ScrollBar/HorizontalLargeIncrease RepeatButton的模板,以扩展其点击/触摸目标,使其与HorizontalSmallIncrease RepeatButton的区域重叠,因此,无论您在哪里单击,它都将完全滚动。

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11808529

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档