UIElementCollection::IndexOf Method (UIElement^)
.NET Framework (current version)
Returns the index position of a specified element in a UIElementCollection.
Assembly: PresentationFramework (in PresentationFramework.dll)
Parameters
- element
-
Type:
System.Windows::UIElement^
The element whose index position is required.
Return Value
Type: System::Int32The index position of the element. -1 if the element is not in the collection.
The following example finds the index position of a UIElement within a UIElementCollection.
<DockPanel Name="ParentElement"> <TextBlock DockPanel.Dock="Top" Name="TxtDisplay"></TextBlock> <Button DockPanel.Dock="Top" Click="FindIndex">What is the Index Number of the Element Just Added?</Button> <DockPanel Name="MainDisplayPanel"> <TextBlock DockPanel.Dock="Top">Text 1</TextBlock> <TextBlock DockPanel.Dock="Top">Text 2</TextBlock> </DockPanel> </DockPanel>
...
.NET Framework
Available since 3.0
Available since 3.0
Show: