【问题标题】:UWP ListView Why Can't I re-order the listUWP ListView 为什么我不能重新排序列表
【发布时间】:2018-11-20 01:19:52
【问题描述】:

我想重新订购我的 ListView 项目。我将它们绑定到 ObservableCollection 并且我正在使用棱镜。 我一定遗漏了一些我遵循的一些教程http://blog.jerrynixon.com/2013/06/walkthrough-reordering-items-in.html 但我无法让它工作。我已经设置了所需的属性

AllowDrop="True"
ReorderMode="Enabled"
CanDragItems="True" 

当我尝试使用鼠标重新订购时,我得到了一个小禁止符号?

这是我的 XAML:

<Grid Margin="1,1,1,1" Background="WhiteSmoke">
    <StackPanel Background="Aquamarine">
        <ListView
            AllowDrop="True"
            SelectionMode="Single"
            CanDragItems="True"
            Width="200"
            Height="200"
            Margin="5"
            HorizontalAlignment="Left"
            BorderBrush="Black"
            BorderThickness="5"
            ItemsSource="{x:Bind ViewModel.People, Mode=TwoWay}"
            ReorderMode="Enabled"
            SelectedItem="{x:Bind ViewModel.SelectedPerson, Mode=TwoWay}">
            <ListView.ItemTemplate>
                <DataTemplate x:DataType="viewmodels:Person">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Margin="5" Text="{x:Bind Name}" />
                        <TextBlock Margin="5" Text="{x:Bind Age}" />
                    </StackPanel>
                </DataTemplate>
            </ListView.ItemTemplate>

        </ListView>
    </StackPanel>
</Grid>

【问题讨论】:

标签: uwp uwp-xaml


【解决方案1】:

我无法重新订购商品的原因是由于此属性。

       CanReorderItems="True"

不要与此属性混淆。

  ReorderMode="Enabled"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-09-17
    • 2018-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-23
    • 1970-01-01
    相关资源
    最近更新 更多