I have nested 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>
When I touch and drag items from inner listbox it plays scroll animation for this inner listbox. How to prevent this behavior? I need to scroll the outer listbox only, but the items from inner listbox still must be selectable.
Thank you!
Try to change Template
of inner ListBox
to be only ItemsPresenter
. This will remove ScrollViewer
which is normally part of that template:
<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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.