2014-03-06 66 views
0

我有嵌套列表框:如何防止內置ListBox在嵌套ListBox中滾動? (WP8)

<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> 

當我觸摸並從內列表框拖動項目它起着滾動動畫該內部列表框。如何防止這種行爲?我只需要滾動外部列表框,但內部列表框中的項目仍然必須可選。

謝謝!

回答

3

嘗試將內部ListBoxTemplate更改爲只有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>