我嵌套了ListBoxes:
<ListBox Name="listbox" Padding="0,0,0,100" Loaded="listbox_Loaded" Foreground="Black">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Name}" FontSize="30" FontWeight="Bold"/>
<ListBox ItemsSource="{Binding Categories}" Foreground="Black">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
当我从内部列表框中触摸并拖动项目时,它会播放此内部列表框的滚动动画。如何防止这种行为?我只需要滚动外部列表框,但内部列表框中的项目仍然必须可选。
谢谢!
尝试将内ListBox
的Template
更改为仅ItemsPresenter
。这将删除通常属于该模板一部分的ScrollViewer
:
<ListBox ItemsSource="{Binding Categories}" Foreground="Black">
<ListBox.Template>
<ControlTemplate TargetType="ListBox">
<ItemsPresenter/>
</ControlTemplate>
</ListBox.Template>
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>