RowDefinitionCollection.Contains(RowDefinition) 方法

定义

确定 RowDefinition 中是否存在给定的 RowDefinitionCollection

public:
 virtual bool Contains(System::Windows::Controls::RowDefinition ^ value);
public bool Contains (System.Windows.Controls.RowDefinition value);
abstract member Contains : System.Windows.Controls.RowDefinition -> bool
override this.Contains : System.Windows.Controls.RowDefinition -> bool
Public Function Contains (value As RowDefinition) As Boolean

参数

value
RowDefinition

标识要测试的 RowDefinition

返回

Boolean

如果集合中存在 RowDefinition,则为 true;否则为 false

实现

示例

下面的示例演示如何使用 Contains 该方法来确定 RowDefinition 是否存在于中 RowDefinitionCollection

private void containsRow(object sender, RoutedEventArgs e)
{
    if (grid1.RowDefinitions.Contains(rowDef1))
    {
        tp2.Text = "Grid Contains RowDefinition rowDef1";
    }
    else
    {
        tp2.Text = "Grid Does Not Contain RowDefinition rowDef1";
    }
}
Private Sub containsRow(ByVal sender As Object, ByVal e As RoutedEventArgs)
    If (grid1.RowDefinitions.Contains(rowDef1)) Then
        tp2.Text = "Grid Contains RowDefinition rowDef1"
    Else
        tp2.Text = "Grid Does Not Contain RowDefinition rowDef1"
    End If
End Sub

若要查看完整的示例,请参阅 如何:使用 ColumnDefinitionsCollections 和 RowDefinitionsCollections 操作列和行

适用于

另请参阅