WP7-水平滚动列表框的问题 [英] WP7 - issues with Horizontal scrolling Listbox
问题描述
我需要一个水平滚动的列表框,并且我遵循了其他一些关于如何实现此问题的建议.
I have a need for a listbox that scrolls horizontally and I have followed the advice from several other questions raised in regard to this as to how to implement.
我目前所进行的滚动操作是水平的,但是在滑动的最后,它并没有停留在滚动到的位置,而是恢复为原始显示-有点像它的松紧带,然后回弹到它的显示.拉伸后的原始位置. 我的列表框包含按钮,我希望用户能够滑动列表框,转到所需的按钮,然后单击该按钮.
What I have currently does scroll horizontally, but at the end of the swipe it does not stay with where I have scrolled to, it reverts back to the original display - a bit like its a piece of elastic that pings back to its original positions after its been stretched. My listbox contains buttons and I want the user to be able to swipe the listbox, get to the button they want and then click that button.
<DataTemplate x:Key="ClassesDisplay">
<Button Height="60" FontSize="12" Content="{Binding ClassName}" />
</DataTemplate>
<ScrollViewer HorizontalScrollBarVisibility="Auto" Margin="0,6,-196,0" Height="Auto" Name="imageScroll">
<ListBox x:Name="ClassesListbox"
Margin="114,371,24,814" Height="60" ItemsSource="{Binding TimetableClasses}"
ItemTemplate="{StaticResource ClassesDisplay}" >
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"></StackPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</ScrollViewer>
AI怀疑我在这里做错了,还是应该以其他方式来做?
AI suspect I am doing something wrong here, or should I be doing this in a different way?
- 谢谢
推荐答案
似乎您没有在ScrollViewer中添加宽度
It seems you are not adding width to your ScrollViewer
尝试添加宽度,例如
<ScrollViewer HorizontalScrollBarVisibility="Auto" Margin="0,6,-196,0" Height="Auto" Name="imageScroll" Width="400">
//Your ListBox
</ScrollViewer>
或者列表框具有内部滚动条,您可以像这样使用它
Or Listbox has internal scroll bar, you can use that like this
<ListBox ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
// your code
>
</ListBox>
这篇关于WP7-水平滚动列表框的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!