WPF ListBox触控设备上的弹性滚动
我在xaml中定义了一个wpf列表框,如下所示WPF ListBox触控设备上的弹性滚动,wpf,listbox,Wpf,Listbox,我在xaml中定义了一个wpf列表框,如下所示 <ListBox HorizontalContentAlignment="Stretch" ItemsSource="{Binding MyCollection}"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Horizontal"/>
<ListBox HorizontalContentAlignment="Stretch" ItemsSource="{Binding MyCollection}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<DockPanel Width="{Binding Path=ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBox}}">
<TextBlock Text="{Binding DisplayText}"></TextBlock>
</DockPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
这提供了一个水平滚动列表框,其中每个项目占用列表框的整个宽度。在触摸设备上使用此功能时,在列表框中拖动手指会以连续的方式在项目中移动,即,我可以拖动手指,让第一个项目的后半部分显示,第二个项目的前半部分显示
我想让项目弹性地默认为占据视口大部分的项目。例如,如果我拖动手指,使第一个项目的三分之一显示,第二个项目的三分之二显示,然后松开手指,列表框将“弹性”滚动到第二个项目。有没有办法用ListBox做到这一点