2013-10-04 30 views
4

我旁邊的XAML主網:WrapGrid水平滾動的Windows 8

<ListView Grid.Row="1" x:Name="NewsListBox"> 
      <ListView.Background> 
       <SolidColorBrush Color="#FF006C67" Opacity="0.5"/> 
      </ListView.Background> 
      <ListView.ItemsPanel> 
       <ItemsPanelTemplate> 
        <WrapGrid Orientation="Vertical"/> 
       </ItemsPanelTemplate> 
      </ListView.ItemsPanel> 
     </ListView> 

而且它看起來不錯,它是如何需要:

不過,這並不滾動內容!

Example

好吧,我加的ScrollViewer:

<ScrollViewer Grid.Row="1" VerticalScrollMode="Disabled" ZoomMode="Disabled"> 
     <ListView Grid.Row="1" x:Name="NewsListBox"> 
      <ListView.Background> 
       <SolidColorBrush Color="#FF006C67" Opacity="0.5"/> 
      </ListView.Background> 
      <ListView.ItemsPanel> 
       <ItemsPanelTemplate> 
        <WrapGrid Orientation="Vertical"/> 
       </ItemsPanelTemplate> 
      </ListView.ItemsPanel> 
     </ListView> 
     </ScrollViewer> 

它垂直堆疊的一切:

Example

我到底做錯了什麼?

回答

5

找到了解決辦法。不需要ScrollViewer。

只需要將ListView替換爲GridView,因爲ListView不適用於水平滾動。

+0

其實,你可以改變的ListView這麼多像GridView控件的行爲。它主要與自定義ItemsPanelTemplate有關。他們甚至使用相同的資源進行造型。 – VasileF

1

你可以試試這個

<ListView 
    ScrollViewer.HorizontalScrollMode="Enabled" 
    ScrollViewer.VerticalScrollMode="Disabled" 
>