System.Windows.Automation.AutomationElement.FindAll C# (CSharp) Method

FindAll() public method

public FindAll ( TreeScope scope, Condition condition ) : AutomationElementCollection
scope TreeScope
condition Condition
return AutomationElementCollection
        public AutomationElementCollection FindAll(TreeScope scope, Condition condition)
        {
            Utility.ValidateArgumentNonNull(condition, "condition");

            try
            {
                UIAutomationClient.IUIAutomationElementArray elemArray =
                    this._obj.FindAllBuildCache(
                        (UIAutomationClient.TreeScope)scope,
                        condition.NativeCondition,
                        CacheRequest.CurrentNativeCacheRequest);
                return AutomationElementCollection.Wrap(elemArray);
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
            }
        }

Usage Example

Example #1
1
 public static void TextPatternRangeFromChildGood(AutomationElement element)
 {
     object patternObj = null;
     if (GetPatternObject(element, TextPattern.Pattern, ref patternObj))
     {
         TextPattern pattern = (TextPattern)patternObj;
         Dump("TextPattern.GetVisibleRanges", true, element);
         try
         {
             AutomationElementCollection collection = element.FindAll(TreeScope.Subtree, Condition.TrueCondition);
             object property = pattern.RangeFromChild(collection[_rnd.Next(collection.Count)]);
         }
         catch (Exception exception)
         {
             VerifyException(element, exception,
                 typeof(ElementNotAvailableException),
                 typeof(InvalidOperationException));
         }
     }
 }
All Usage Examples Of System.Windows.Automation.AutomationElement::FindAll