語言

RowDefinitionCollection.Insert(Int32, RowDefinition) 方法

定義

在指定的索引位置RowDefinition插入 aRowDefinitionCollection。

public:
 virtual void Insert(int index, System::Windows::Controls::RowDefinition ^ value);
public void Insert(int index, System.Windows.Controls.RowDefinition value);
abstract member Insert : int * System.Windows.Controls.RowDefinition -> unit
override this.Insert : int * System.Windows.Controls.RowDefinition -> unit
Public Sub Insert (index As Integer, value As RowDefinition)

參數

index
Int32

該物品在集合中插入的位置。

value
RowDefinition

RowDefinition插入。

實作

例外狀況

index 在 中 不是有效的索引 IList。

範例

以下範例示範如何使用此 Insert 方法將 a RowDefinition 插入 indexRowDefinitionCollection到 。

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 操作欄位與列」。

備註

RowDefinitionCollection 使用零基索引系統。

適用於

另請參閱