System.Windows.Automation.CacheRequest.Add C# (CSharp) Method

Add() public method

public Add ( AutomationPattern pattern ) : void
pattern AutomationPattern
return void
        public void Add(AutomationPattern pattern)
        {
            Utility.ValidateArgumentNonNull(pattern, "pattern");
            lock (this._lock)
            {
                this.CheckAccess();
                this._obj.AddPattern(pattern.Id);
            }
        }

Same methods

CacheRequest::Add ( AutomationProperty property ) : void

Usage Example

		public IEnumerable<ITab> GetTabsOfWindow(IntPtr hWnd)
		{
			var notepadPlusPlusWindow = AutomationElement.FromHandle(hWnd);

			var cacheRequest = new CacheRequest();
			cacheRequest.Add(AutomationElement.NameProperty);
			cacheRequest.Add(AutomationElement.LocalizedControlTypeProperty);
			cacheRequest.Add(SelectionItemPattern.Pattern);
			cacheRequest.Add(SelectionItemPattern.SelectionContainerProperty);
			cacheRequest.TreeScope = TreeScope.Element;

			AutomationElement tabBarElement;

			using (cacheRequest.Activate())
			{
				tabBarElement = notepadPlusPlusWindow.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.LocalizedControlTypeProperty, "tab"));
			}

			if(tabBarElement == null)
				yield break;

			var tabElements = tabBarElement.FindAll(TreeScope.Children, new PropertyCondition(AutomationElement.LocalizedControlTypeProperty, "tab item"));

			for (var tabIndex = 0; tabIndex < tabElements.Count; tabIndex++)
			{
				yield return new NotepadPlusPlusTab(tabElements[tabIndex]);
			}
		}
All Usage Examples Of System.Windows.Automation.CacheRequest::Add