如何防止内部列表框在嵌套列表框中滚动?(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>

当我从内部列表框中触摸并拖动项目时,它会播放此内部列表框的滚动动画。如何防止这种行为?我只需要滚动外部列表框,但内部列表框中的项目仍然必须可选。

谢谢!

尝试将内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>

最新更新