2015-02-11 94 views
0

我有以下XAML:啓用水平滾動XAML

 <Grid> 

      <ListView x:Name="IconTextGrid" Height="500"> 
       <ListView.ItemTemplate> 
        <DataTemplate> 
         <StackPanel Orientation="Horizontal" Width="220" Height="60"> 
          <Border Background="#66727272" Width="40" Height="40" Margin="10"> 
           <Image Source="/SampleImage.png" Height="32" Width="32" Stretch="UniformToFill"/> 
          </Border> 
          <StackPanel Orientation="Vertical" VerticalAlignment="Center"> 
           <TextBlock Text="Ay Lorem Ipsum" Margin="10,0,0,0" Width="170" Height="20" TextTrimming="WordEllipsis" /> 
           <TextBlock Text="Dolor sit amet" Margin="10,0,0,0" Width="170" Height="20" TextTrimming="WordEllipsis"/> 
          </StackPanel> 
         </StackPanel> 
        </DataTemplate> 

       </ListView.ItemTemplate> 
       <ListView.ItemsPanel> 
        <ItemsPanelTemplate> 
         <ItemsWrapGrid MaximumRowsOrColumns="8"/> 
        </ItemsPanelTemplate> 
       </ListView.ItemsPanel> 
       <ScrollViewer HorizontalScrollMode="Auto" HorizontalScrollBarVisibility="Auto"/> 
      </ListView> 

     </Grid> 
</Page> 

原本應該呈現可以由用戶選擇的項目。 這裏的問題是,當我有超過幾個項目(如超過100)沒有水平滾動。 我的問題是爲什麼以及如何修復它? 謝謝。

回答

0

嘗試這樣做...

<Grid> 
    <ScrollViewer HorizontalScrollMode="Auto" HorizontalScrollBarVisibility="Auto"> 
    <ListView x:Name="IconTextGrid" Height="500"> 
      <ListView.ItemTemplate> 
       <DataTemplate> 
        <StackPanel Orientation="Horizontal" Width="220" Height="60"> 
         <Border Background="#66727272" Width="40" Height="40" Margin="10"> 
          <Image Source="/SampleImage.png" Height="32" Width="32" Stretch="UniformToFill"/> 
         </Border> 
         <StackPanel Orientation="Vertical" VerticalAlignment="Center"> 
          <TextBlock Text="Ay Lorem Ipsum" Margin="10,0,0,0" Width="170" Height="20" TextTrimming="WordEllipsis" /> 
          <TextBlock Text="Dolor sit amet" Margin="10,0,0,0" Width="170" Height="20" TextTrimming="WordEllipsis"/> 
         </StackPanel> 
        </StackPanel> 
       </DataTemplate> 
      </ListView.ItemTemplate> 
      <ListView.ItemsPanel> 
       <ItemsPanelTemplate> 
        <ItemsWrapGrid MaximumRowsOrColumns="8"/> 
       </ItemsPanelTemplate> 
      </ListView.ItemsPanel>     
     </ListView> 
    </ScrollViewer> 
</Grid> 
+0

謝謝,但它不工作 – Tal 2015-02-11 07:33:32

+0

對不起我錯地方的ScrollViewer網格單元內... ,並把你想在被滾動的元素ScrollViewer標記.. – 2015-02-11 07:38:38

+0

感謝它的工作原理,但當我嘗試使用鼠標滾輪滾動時,它不響應 – Tal 2015-02-11 07:45:28