【问题标题】:How to prevent the inner ListBox's scrolling in nested ListBoxes? (WP8)如何防止内部列表框在嵌套列表框中滚动? (WP8)
【发布时间】:2014-03-06 21:03:34
【问题描述】:

我已经嵌套了 ListBox:

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

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

谢谢!

【问题讨论】:

    标签: c# xaml windows-phone-8 windows-phone


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-03
      • 1970-01-01
      • 2023-03-21
      相关资源
      最近更新 更多