2015-04-22 135 views
0

我有以下ListView控件:的ListView左右移動,同時滾動

<ListView ItemsSource="{Binding ArtistList}"> 
    <ListView.ItemTemplate> 
     <DataTemplate> 
      <Border BorderThickness="0,0,0,0.5" BorderBrush="#22ffffff" Tapped="ArtistTapped"> 
       <Grid> 
        <Grid.ColumnDefinitions> 
         <ColumnDefinition Width="Auto"/> 
         <ColumnDefinition Width="*"/> 
        </Grid.ColumnDefinitions> 
        <Ellipse Grid.Column="0" Canvas.ZIndex="0" Fill="#22ffffff" Width="50" Height="50" Margin="0,10"/> 
        <Ellipse Grid.Column="0" Canvas.ZIndex="1" Stretch="UniformToFill" Width="50" Height="50" Margin="0,10"> 
         <Ellipse.Fill> 
          <ImageBrush ImageSource="{Binding firstAlbumArt}"/> 
         </Ellipse.Fill> 
        </Ellipse> 
        <StackPanel Grid.Column="1" Margin="20,10,0,10"> 
         <TextBlock Text="{Binding name}" Foreground="#ffffffff" FontFamily="Segoe WP" FontSize="18"/> 
         <TextBlock Foreground="#aaffffff" FontFamily="Segoe WP" FontWeight="Light" FontSize="14"> 
          <Run Text="{Binding amountofalbums}"/> 
          <Run Text="album(s)"/> 
         </TextBlock> 
        </StackPanel> 
       </Grid> 
      </Border> 
     </DataTemplate> 
    </ListView.ItemTemplate> 
    <ListView.ItemContainerStyle> 
     <Style TargetType="ListViewItem"> 
      <Setter Property="HorizontalContentAlignment" Value="Stretch" /> 
     </Style> 
    </ListView.ItemContainerStyle> 
</ListView> 

當我向上和向下滾動,ListView控件稍微移動左右,這是很讓人討厭。有兩種方法來解決這個問題:

  • 卸下ItemContainerStyle =>項目不再捉襟見肘這是必要的

  • 添加的Horizo​​ntalAlignment =左到ListView =>再次,項目AREN」牛逼拉長了...

有沒有辦法讓ListView的跳轉左右,同時保持拉伸ListViewItems?

回答

0

ListView中設置ScrollViewer.HorizontalScrollMode="Disabled"。它應該停止不需要的滾動行爲。

<ListView ItemsSource="{Binding ArtistList}" ScrollViewer.HorizontalScrollMode="Disabled"> 
    <!-- rest of xaml code --> 
</ListView> 
+0

不幸的是,我已經嘗試過這一點,它並沒有解決問題。 –