[英]How to prevent the inner ListBox's scrolling in nested ListBoxes? (WP8)
我嵌套了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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.