共用方式為


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

傳回

如果集合內存在 RowDefinition,則為 true,否則為 false

實作

範例

下列範例示範如何使用 Contains 方法來判斷 是否存在 RowDefinitionRowDefinitionCollection 中。

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

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

適用於

另請參閱