Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

UIElementCollection.Contains Method (UIElement)

 

Determines whether a specified element is in the UIElementCollection.

Namespace:   System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

Public Overridable Function Contains (
	element As UIElement
) As Boolean

Parameters

element
Type: System.Windows.UIElement

The element to find.

Return Value

Type: System.Boolean

true if the specified UIElement is found in the collection; otherwise, false.

The following example uses the Contains method to determine if a specific UIElement exists within a UIElementCollection.

Private Sub ClearButtons(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
    sp1.Children.Clear()
    btn = New Button()
    btn.Content = "Click to clear"
    sp1.Children.Add(btn)
    AddHandler btn.Click, AddressOf Me.ClearControls
    btn1 = New Button()
    btn1.Content = "Click to clear"
    sp1.Children.Add(btn1)
    AddHandler btn1.Click, AddressOf Me.ClearControls
    btn2 = New Button()
    btn2.Content = "Click to clear"
    sp1.Children.Add(btn2)
    AddHandler btn2.Click, AddressOf Me.ClearControls
    btn3 = New Button()
    btn3.Content = "Click to clear"
    sp1.Children.Add(btn3)
    AddHandler btn3.Click, AddressOf Me.ClearControls
End Sub

Private Sub ClearControls(ByVal sender As Object, ByVal e As RoutedEventArgs)
    sp1.Children.Clear()
End Sub

.NET Framework
Available since 3.0
Return to top
Show:
© 2016 Microsoft