语言

ListViewBase.CanReorderItems 属性

定义

获取或设置一个值,该值指示是否可以通过用户交互对视图中的项重新排序。

public:
 property bool CanReorderItems { bool get(); void set(bool value); };
bool CanReorderItems();

void CanReorderItems(bool value);
public bool CanReorderItems { get; set; }
var boolean = listViewBase.canReorderItems;
listViewBase.canReorderItems = boolean;
Public Property CanReorderItems As Boolean
<listViewBase CanReorderItems="bool" />

属性值

Boolean

bool

true 如果视图中的项目可以通过用户交互重新排序,否则,为 false. 默认值为 false。

示例

下面是一个 GridView ,其中包含 6 个矩形,用户可以通过拖放重新排序。

<GridView MaxHeight="310" 
          AllowDrop="True" 
          CanReorderItems="True">
    <Rectangle Height="100" Width="100" Fill="Blue"/>
    <Rectangle Height="100" Width="100" Fill="Red"/>
    <Rectangle Height="100" Width="100" Fill="Yellow"/>
    <Rectangle Height="100" Width="100" Fill="Green"/>
    <Rectangle Height="100" Width="100" Fill="Gray"/>
    <Rectangle Height="100" Width="100" Fill="LightBlue"/>
</GridView>

注解

若要使用户能够使用拖放交互对项目重新排序,必须将和 AllowDrop 属性都true设置为 CanReorderItems 。

当项目分组或 将 VariableSizedWrapGrid 用作 ItemsPanel 时,不支持内置重新排序。

将 IsSwipeEnabled 设置为 false 禁用某些默认触摸交互,因此应在需要这些交互时将其 true 设置为。 例如:

  • 如果启用了项目选择,并且已将 IsSwipeEnabled 设置为 false,则用户可以通过右键单击鼠标来取消选择项目,但无法使用 轻扫 手势取消选择具有触摸的项目。
  • 如果将 CanDragItems 设置为 trueIsSwipeEnabledfalse,则用户可以使用鼠标拖动项目,但不能使用触摸。
  • 如果将 CanReorderItems 设置为 trueIsSwipeEnabledfalse,则用户可以使用鼠标对项重新排序,但不能使用触摸对项进行排序。

Important

若要在重新排序项目时接收 DragItemsStarting 和 DragItemsCompleted 事件, 必须将 CanDragItems 属性设置为 true。

适用于

另请参阅