2

我有一个 ScrollViewer,它包含一个包含 2 个 ListViews 的 Horizo​​ntal StackPanel。

我的目标是让 2 个 ListView 一起滚动。我遇到的问题是我无法禁用 ListViews 中的内置 ScrollViewers ......无论我做什么,它们都会继续独立滚动。我真的必须错过一些东西......任何帮助将不胜感激。

这是我的 XAML:

<ScrollViewer VerticalScrollBarVisibility="Visible" 
          HorizontalScrollBarVisibility="Disabled" 
          ZoomMode="Disabled" 
          HorizontalAlignment="Left" 
          VerticalAlignment="Top" 
          Width="830" 
          Height="500">

  <StackPanel x:Name="teesSP" 
              HorizontalAlignment="Left" 
              Height="500" 
              Width="830" 
              Orientation="Horizontal" 
              VerticalAlignment="Top">

      <ListView x:Name="timesLV1" 
                HorizontalAlignment="Left" 
                Width="130" 
                Height="500" 
                ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                ScrollViewer.HorizontalScrollMode="Disabled"
                ScrollViewer.IsHorizontalRailEnabled="False"
                ScrollViewer.IsHorizontalScrollChainingEnabled="False"
                ScrollViewer.IsScrollInertiaEnabled="False"
                ScrollViewer.IsVerticalRailEnabled="False"
                ScrollViewer.IsVerticalScrollChainingEnabled="False"
                ScrollViewer.IsZoomChainingEnabled="False"
                ScrollViewer.IsZoomInertiaEnabled="False"
                ScrollViewer.VerticalScrollBarVisibility="Disabled"
                ScrollViewer.VerticalScrollMode="Disabled"
                BorderThickness="2" 
                BorderBrush="Black" 
                VerticalAlignment="Top" 
                ItemTemplate="{StaticResource TimeTileTemplate}"
                SelectionMode="Single" 
                SelectionChanged="timesLV_Click" />

      <ListView x:Name="timesLV2" 
                HorizontalAlignment="Left" 
                Width="700" 
                Height="500" 
                ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                ScrollViewer.HorizontalScrollMode="Disabled"
                ScrollViewer.IsHorizontalRailEnabled="False"
                ScrollViewer.IsHorizontalScrollChainingEnabled="False"
                ScrollViewer.IsScrollInertiaEnabled="False"
                ScrollViewer.IsVerticalRailEnabled="False"
                ScrollViewer.IsVerticalScrollChainingEnabled="False"
                ScrollViewer.IsZoomChainingEnabled="False"
                ScrollViewer.IsZoomInertiaEnabled="False"
                ScrollViewer.VerticalScrollBarVisibility="Disabled"
                ScrollViewer.VerticalScrollMode="Disabled"
                BorderThickness="2" 
                BorderBrush="Black" 
                VerticalAlignment="Top" 
                ItemTemplate="{StaticResource TimeTileTemplate}"
                SelectionMode="Single" 
                SelectionChanged="timesLV_Click" />

  </StackPanel>

</ScrollViewer>
4

1 回答 1

5

这是因为您为每个 ListView 指定了一定的宽度和高度。从 ListView 和 StackPanel 中删除宽度和高度,仅用于滚动查看器。

然后,您只需使 ScrollViewer 具有固定的高度或包含它的网格的大小。

于 2012-08-28T19:38:59.733 回答