RowDefinitionCollection.IndexOf(RowDefinition) 方法

定義

傳回 RowDefinition 內指定之 RowDefinitionCollection 的索引位置。

public:
 virtual int IndexOf(System::Windows::Controls::RowDefinition ^ value);
public int IndexOf (System.Windows.Controls.RowDefinition value);
abstract member IndexOf : System.Windows.Controls.RowDefinition -> int
override this.IndexOf : System.Windows.Controls.RowDefinition -> int
Public Function IndexOf (value As RowDefinition) As Integer

參數

value
RowDefinition

擁有所需索引位置的 RowDefinition

傳回

Int32

如果可在集合中找到,即為 value 的索引,否則為 -1。

實作

範例

下列範例示範如何使用 IndexOf 方法來判斷 內的 RowDefinitionCollection 索引位置 RowDefinition

private void insertRowAt(object sender, RoutedEventArgs e)
{
    rowDef1 = new RowDefinition();
    grid1.RowDefinitions.Insert(grid1.RowDefinitions.Count, rowDef1);
    tp1.Text = "RowDefinition added at index position " + grid1.RowDefinitions.IndexOf(rowDef1).ToString();
}
Private Sub insertRowAt(ByVal sender As Object, ByVal e As RoutedEventArgs)
    Dim rowDef1 As New RowDefinition
    grid1.RowDefinitions.Insert(grid1.RowDefinitions.Count, rowDef1)
    tp1.Text = "RowDefinition added at index position " + grid1.RowDefinitions.IndexOf(rowDef1).ToString()
End Sub

若要檢視完整的範例,請參閱 如何:使用 ColumnDefinitionsCollections 和 RowDefinitionsCollections 運算元據行和資料列

適用於

另請參閱