EzListItem

EzListItem is created using an existing element who has a ControlType of ListItem. This class opens up list item specific functionality; this element type will always have a parent list
💡 Note

If the underlying element being used to construct EzListItem does not have a ControlType of ListItem, an exception will be thrown on construction

Syntax

        public class EzListItem : EzElement

Constructors

Name Input Description
EzListItem(EzElement element) EzElement Creates a new instance of EzListItem based on an existing EzElement
EzListItem(EzRoot root) EzRoot Creates a new instance of EzListItem based on an existing EzRoot
EzListItem(AutomationElement element) AutomationElement Creates a new instance of EzListItem based on an existing AutomationElement

Properties

Name Type Description
SelectionItemPattern SelectionItemPattern Houses the underlying windows SelectionItemPattern. Will return null if ExposeBackingWindowsPatterns is not set to true
ScrollItemPattern ScrollItemPattern Houses the underlying windows ScrollItemPattern. Will return null if ExposeBackingWindowsPatterns is not set to true
VirtualizedItemPattern VirtualizedItemPattern Houses the underlying windows VirtualizedItemPattern. Will return null if ExposeBackingWindowsPatterns is not set to true
Container EzList Houses the EzList that contains the current EzListItem

Methods

Name Return Type Description
ScrollItemIntoView() void Scrolls the current EzListItem into view
SelectItem() void Selects the curent EzListItem
AddItemToSelection() void Adds the current EzListItem to the items that are selected. Note that if the parent EzList does not allow selecting multiple items, this method will do nothing
RemoveItemFromSelection() void Removes the current EzListItem to the items that are selected. Note that if the parent EzList does not allow selecting multiple items, this method will do nothing

Samples and Usage

The EzListItem element is usually constructed with an instance of EzElement (or more practically, EzList). It provides functionality specific to an item within a list.

Sample:

        //Simple method to launch Windows' built in calculator application
        const string calculatorPath = C:\\Windows\\System32\\calc.exe";

        //Get an instance of EzProcess in order to create EzRoot.  Wrap it in a using statement to ensure that
        //.Dispose() is called
        using (EzProcess process = new EzProcess(calculatorPath, "Calculator"))
        {
            process.StartProcess();

            //Get the root element of the application
            EzRoot root = new EzRoot(process);

            //Use the .FindChildByAutomationId to query all children of the root for the first element whose
            //AutomationId property is equal to "TestListName"
            EzElement element = root.RootElement.FindChildByAutomationId("TestListName");

            //Create a new list element
            EzList list = new EzList(element);

            //Find a list element whose name is "TestListItem"
            EzElement listItemElement = list.FindChildByAutomationId("TestListItem");

            //Create an EzListItem element based on the listItemElement that we found
            EzListItem listItem = new EzListItem(listItemElement);

            //Scroll the list item into view
            listItem.ScrollItemIntoView();
        }