Språk

RowDefinitionCollection.IndexOf(RowDefinition) Metod

Definition

Returnerar indexpositionen för en angiven RowDefinition inom en 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

Parametrar

value
RowDefinition

Vars RowDefinition indexposition är önskad.

Returer

Indexet för value om det finns i samlingen, annars -1.

Implementeringar

Exempel

I följande exempel visas hur du använder IndexOf metoden för att fastställa indexpositionen för en RowDefinition inom en RowDefinitionCollection.

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

Information om hur du visar det fullständiga exemplet finns i Ändra kolumner och rader med Hjälp av ColumnDefinitionsCollections och RowDefinitionsCollections.

Gäller för

Se även