GeneratorPosition GeneratorPosition GeneratorPosition GeneratorPosition Struct

定義

GeneratorPosition 可用來描述由 ItemContainerGenerator 管理之項目的位置。GeneratorPosition is used to describe the position of an item that is managed by ItemContainerGenerator.

public value class GeneratorPosition
public struct GeneratorPosition
type GeneratorPosition = struct
Public Structure GeneratorPosition
繼承
GeneratorPositionGeneratorPositionGeneratorPositionGeneratorPosition

範例

下列範例說明如何使用GeneratorPosition , 從專案清單的開頭開始向前產生。The following example illustrates how to use GeneratorPosition to start generating forward from the beginning of an item list.

// Start generating items forward from the beginning of the item list
GeneratorPosition position = new GeneratorPosition(-1, 0);
GeneratorDirection direction = GeneratorDirection.Forward;
IItemContainerGenerator generator = (IItemContainerGenerator)this.itemsControl.ItemContainerGenerator;
generator.StartAt(position, direction);
' Start generating items forward from the beginning of the item list
Dim position As New GeneratorPosition(-1, 0)
Dim direction As GeneratorDirection = GeneratorDirection.Forward
Dim generator As IItemContainerGenerator = CType(Me.itemsControl.ItemContainerGenerator, IItemContainerGenerator)
generator.StartAt(position, direction)

下列範例說明如何使用GeneratorPosition從專案清單結尾處開始產生反向。The following example illustrates how to use GeneratorPosition to start generating backward from the end of an item list.

// Start generating items backward from the end of the item list
GeneratorPosition position = new GeneratorPosition(-1, 0);
GeneratorDirection direction = GeneratorDirection.Backward;
IItemContainerGenerator generator = (IItemContainerGenerator)this.itemsControl.ItemContainerGenerator;
generator.StartAt(position, direction);
' Start generating items backward from the end of the item list
Dim position As New GeneratorPosition(-1, 0)
Dim direction As GeneratorDirection = GeneratorDirection.Backward
Dim generator As IItemContainerGenerator = CType(Me.itemsControl.ItemContainerGenerator, IItemContainerGenerator)
generator.StartAt(position, direction)

下列範例說明如何使用GeneratorPosition從專案清單的中間開始產生正向。The following example illustrates how to use GeneratorPosition to start generating forward from the middle of an item list.

// Start generating items forward,
// starting with the first unrealized item (offset of 1),
// after the 5th realized item
// (the item with index 4 among all realized items) in the list
GeneratorPosition position = new GeneratorPosition(4, 1);
GeneratorDirection direction = GeneratorDirection.Forward;
IItemContainerGenerator generator = (IItemContainerGenerator)this.itemsControl.ItemContainerGenerator;
generator.StartAt(position, direction);
' Start generating items forward,
' starting with the first unrealized item (offset of 1),
' after the 5th realized item
' (the item with index 4 among all realized items) in the list
Dim position As New GeneratorPosition(4, 1)
Dim direction As GeneratorDirection = GeneratorDirection.Forward
Dim generator As IItemContainerGenerator = CType(Me.itemsControl.ItemContainerGenerator, IItemContainerGenerator)
generator.StartAt(position, direction)

備註

GeneratorPosition 可由 StartAt 使用。GeneratorPosition is used by StartAt.

建構函式

GeneratorPosition(Int32, Int32) GeneratorPosition(Int32, Int32) GeneratorPosition(Int32, Int32) GeneratorPosition(Int32, Int32)

使用指定的索引和位移,初始化 GeneratorPosition 的新執行個體。Initializes a new instance of GeneratorPosition with the specified index and offset.

屬性

Index Index Index Index

取得或設定與產生的 (實現的) 項目相關的 Int32 索引。Gets or sets the Int32 index that is relative to the generated (realized) items.

Offset Offset Offset Offset

取得或設定與索引項目附近之未產生的 (未實現的) 項目相關的 Int32 位移。Gets or sets the Int32 offset that is relative to the ungenerated (unrealized) items near the indexed item.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

比較 GeneratorPosition 之指定的執行個體和目前執行個體的值是否相等。Compares the specified instance and the current instance of GeneratorPosition for value equality.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

傳回這個 GeneratorPosition 的雜湊程式碼。Returns the hash code for this GeneratorPosition.

ToString() ToString() ToString() ToString()

傳回這個 GeneratorPosition 之執行個體的字串表示。Returns a string representation of this instance of GeneratorPosition.

運算子

Equality(GeneratorPosition, GeneratorPosition) Equality(GeneratorPosition, GeneratorPosition) Equality(GeneratorPosition, GeneratorPosition) Equality(GeneratorPosition, GeneratorPosition)

比較兩個 GeneratorPosition 物件的值是否相等。Compares two GeneratorPosition objects for value equality.

Inequality(GeneratorPosition, GeneratorPosition) Inequality(GeneratorPosition, GeneratorPosition) Inequality(GeneratorPosition, GeneratorPosition) Inequality(GeneratorPosition, GeneratorPosition)

比較兩個 GeneratorPosition 物件的值是否不相等。Compares two GeneratorPosition objects for value inequality.

適用於