RowDefinitionCollection.IndexOf(RowDefinition) 方法

定义

返回给定 RowDefinitionRowDefinitionCollection 中的索引位置。

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 操作列和行

适用于

另请参阅