Share via


Layout.IndexBasedLayoutOrientation 屬性

定義

取得方向,如果有的話,專案會根據來源集合中的索引進行配置。

public:
 property IndexBasedLayoutOrientation IndexBasedLayoutOrientation { IndexBasedLayoutOrientation get(); };
IndexBasedLayoutOrientation IndexBasedLayoutOrientation();
public IndexBasedLayoutOrientation IndexBasedLayoutOrientation { get; }
var indexBasedLayoutOrientation = layout.indexBasedLayoutOrientation;
Public ReadOnly Property IndexBasedLayoutOrientation As IndexBasedLayoutOrientation

屬性值

列舉值,指出方向,如果有的話,專案會根據來源集合中的索引進行配置。 默認值為 None (請參閱) 。

備註

每個 Layout衍生類別都可以指定此屬性的預設值。 NonVirtualizingLayout 和 VirtualizingLayout 都會指定 IndexBasedLayoutOrientation.None 做為預設值。 LinedFlowLayout 指定 LeftToRight。 自定義版面配置會呼叫受保護的 SetIndexBasedLayoutOrientation 方法來設定此屬性的值。

您可以使用 IndexBasedLayoutOrientation 屬性來判斷索引處的專案是否位於索引 N+1N (或索引) 專案下方。 這可讓 ItemsView 之類的控制程式使用箭頭鍵正確實作鍵盤流覽。

屬性 IndexBasedLayoutOrientation 對per se 沒有任何作用 Layout 。 相反地,它可以對取用 Layout的控件產生效果,例如 ItemsView 控件。 會 ItemsView 在其 TryGetItemIndex 方法的內部實作中,使用這個屬性的值,以及其內建的鍵盤型導覽處理。

例如, LinedFlowLayout 版面配置會 LeftToRight指定 。 因此,向右鍵和向左鍵會根據其索引移至專案。 向右鍵會巡覽至下一個索引, (從索引 N 移至索引 N+1) 。 向左鍵會巡覽至上一個索引 (從索引 N 移至索引 N-1) 。 另一方面,向上鍵和向下箭頭鍵會根據其實體位置移至專案。

當 為 TopToBottomIndexBasedLayoutOrientation,行為會反轉。

當 是 NoneIndexBasedLayoutOrientation,所有四個箭頭鍵都會根據其實體位置移至專案,而不是其索引。

此表格中的圖例會以可視化方式表示 的 IndexBasedLayoutOrientation可能值。

IndexBasedLayoutOrientation 範例說明
LeftToRight
專案會以水準方式配置,並增加索引。
IndexBasedLayoutOrientation 的 LeftToRight 值圖例
TopToBottom
專案會以垂直方式配置,並增加索引。
IndexBasedLayoutOrientation 的 TopToBottom 值圖例
None
專案版面配置與其索引編號之間沒有相互關聯。
IndexBasedLayoutOrientation 的 None 值圖例

適用於

另請參閱