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.
IViewAutomationPeer Interface
Visual Studio 2010
Namespace:
System.Windows.Automation.Peers
Assembly: PresentationFramework (in PresentationFramework.dll)
The IViewAutomationPeer type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | CreateItemAutomationPeer | Creates a new instance of the ItemAutomationPeer class. |
![]() | GetAutomationControlType | Gets the control type for the element that is associated with this IViewAutomationPeer. |
![]() | GetChildren | Gets the collection of immediate child elements of the specified UI Automation peer. |
![]() | GetPattern | Gets the control pattern that is associated with the specified patternInterface. |
![]() | ItemsChanged | Called by ListView when the collection of items changes. |
![]() | ViewDetached | Called when the custom view is no longer applied to the ListView. |
The following code shows a custom view implementing IViewAutomationPeer in a separate class to handle a button that appears at the top of the ListView control.
Public Class OneButtonHeaderView Inherits ViewBase Protected Overrides Function GetAutomationPeer(ByVal parent As ListView) As IViewAutomationPeer Return New OneButtonHeaderViewAutomationPeer(Me, parent) End Function ... Public Class OneButtonHeaderViewAutomationPeer Implements IViewAutomationPeer Private m_lv As ListView Public Sub New(ByVal control As OneButtonHeaderView, ByVal parent As ListView) m_lv = parent End Sub Private Function CreateItemAutomationPeer(ByVal item As Object) As ItemAutomationPeer Implements IViewAutomationPeer.CreateItemAutomationPeer Dim lvAP As ListViewAutomationPeer = TryCast(UIElementAutomationPeer.FromElement(m_lv), ListViewAutomationPeer) Return New ListBoxItemAutomationPeer(item, lvAP) End Function Private Function GetAutomationControlType() As AutomationControlType Implements IViewAutomationPeer.GetAutomationControlType Return AutomationControlType.List End Function Private Function GetChildren(ByVal children As List(Of AutomationPeer)) As List(Of AutomationPeer) Implements IViewAutomationPeer.GetChildren ' the children parameter is a list of automation peers for all the known items ' our view must add its banner button peer to this list. Dim b As Button = CType(m_lv.Template.FindName("BannerButton", m_lv), Button) Dim peer As AutomationPeer = UIElementAutomationPeer.CreatePeerForElement(b) 'If children is null, we still need to create an empty list to insert the button If children Is Nothing Then children = New List(Of AutomationPeer)() End If children.Insert(0, peer) Return children End Function Private Function GetPattern(ByVal patternInterface As PatternInterface) As Object Implements IViewAutomationPeer.GetPattern ' we can invoke the banner button If patternInterface = PatternInterface.Invoke Then Dim b As Button = CType(m_lv.Template.FindName("BannerButton", m_lv), Button) Dim peer As AutomationPeer = UIElementAutomationPeer.FromElement(b) If peer IsNot Nothing Then Return peer End If End If ' if this view does not have special handling for the pattern interface, return null ' the ListViewAutomationPeer.GetPattern default handling will be used. Return Nothing End Function Private Sub ItemsChanged(ByVal e As System.Collections.Specialized.NotifyCollectionChangedEventArgs) Implements IViewAutomationPeer.ItemsChanged End Sub Private Sub ViewDetached() Implements IViewAutomationPeer.ViewDetached End Sub End Class
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Community Additions
Show:
