2012-08-04 56 views
0

我有以下列表框控件放置在網格內,但列表框不正確水平滾動。如果您將滾動條拖過來,它可以正常工作,但如果您單擊箭頭,則只能滾動一半。我該如何解決這個問題?C#Windows RT列表框水平滾動問題

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

感謝

+0

你的ListBox上有任何項目嗎? – 2012-08-04 12:35:41

+0

是的,我以編程方式將項目添加到列表框。如果我拖動滾動條,滾動工作正常。 – 2012-08-04 14:04:43

回答

1

貌似在WinRT中給我的錯誤。你仍然可以點擊Horizo​​ntalLargeIncrease RepeatButton並且工作。也許您可以編輯ListBox/ScrollViewer/ScrollBar/Horizo​​ntalLargeIncrease RepeatButton的模板來擴展其點擊/觸摸目標,以重疊Horizo​​ntalSmallIncrease RepeatButton的區域,因此無論您單擊哪個位置,它都會繼續滾動。

或者,您可以將ListBox.ItemsPanel/ItemsPanelTemplate設置爲StackPanel。請注意,默認情況下,VirtualizingStackPanel對於長列表更好,因爲它不會生成與StackPanel相對的綁定集合中的所有項目,但似乎您看到的問題是VirtualizingStackPanel。

+0

詢問有關MSDN論壇上的錯誤:http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/33415918-dfa2-46da-9b7f-65fcc2114042 – 2012-08-05 07:11:01

+1

謝謝菲利普。我還注意到,用ScrollViewer控件包裝ListBox控件似乎也可以。 – 2012-08-05 11:19:20