語言

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。

範例

這裡有一個包含 6 個矩形的 GridView ,使用者可以透過拖放方式重新排序。

<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 屬性都CanReorderItems設為 true。

當物品被分組或使用 VariableSsizeWrapGrid 作為 ItemsPanel 時,內建的重新排序功能不被支援。

將 IsSwipeEnabled 設定為 false 禁用某些預設觸控互動,因此應該設定為 true 需要這些互動時使用。 例如:

  • 如果啟用了物品選擇並將 IsSwipeEnabled 設定為 false,使用者可以透過滑鼠右鍵點擊取消選取項目,但無法透過滑 動 手勢用觸控取消選取項目。
  • 如果你把 CanDragItems 設為 ,trueIsSwipeEnabled 設為 false,使用者可以用滑鼠拖曳物品,但不能用觸控。
  • 如果你把 CanReorderItems 設為 ,trueIsSwipeEnabled 設為 false,使用者可以用滑鼠重新排序物品,但不能用觸控操作。

Important

為了在重新排序物品時接收 DragItemsStarting 和 DragItemsCompleted 事件, CanDragItems 屬性必須設定為 true。

適用於

另請參閱