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>

備註

若要讓使用者使用拖放互動重新排序專案,您必須將 CanReorderItemsAllowDrop 屬性都設定為 true

當專案分組時,或 當 VariableSizedWrapGrid 當做 ItemsPanel使用時,不支援內建重新排序。

IsSwipeEnabled 設定為 false 停用一些預設觸控互動,因此當需要這些互動時,應該將其設定 true 為 。 例如:

  • 如果已啟用專案選取範圍,且您將 IsSwipeEnabledfalse 設定為 ,則使用者可以使用滑鼠右鍵按一下來取消選取專案,但無法使用 動手勢取消選取具有觸控的專案。
  • 如果您將 CanDragItems 設定為 true並將 IsSwipeEnabled 設定為 false ,使用者可以使用滑鼠拖曳專案,但不能使用觸控。
  • 如果您將 CanReorderItems 設定為 true並將 IsSwipeEnabled 設定為 false ,則使用者可以使用滑鼠重新排序專案,但不能使用觸控。

重要

若要在重新排序專案時接收 DragItemsStartingDragItemsCompleted 事件, CanDragItems 屬性必須設定為 true

適用於

另請參閱