System.Windows.Automation.Peers.ButtonAutomationPeer.GetPattern C# (CSharp) Method

GetPattern() public method

public GetPattern ( PatternInterface patternInterface ) : object
patternInterface PatternInterface
return object
		public override object GetPattern (PatternInterface patternInterface)
		{
			if (patternInterface == PatternInterface.Invoke)
				return this;
			return base.GetPattern (patternInterface);
		}

Usage Example

        public override string DoImpl()
        {
            var buttonName = this.Action == With.Accept ? "LeftButton" : "RightButton";

            var popups = VisualTreeHelper.GetOpenPopups();
            foreach (var popup in popups)
            {
                var popupChild = popup.Child;
                var element = (FrameworkElement)Finder.GetDescendantsBy(popupChild, new By("name", buttonName)).FirstOrDefault() as Button;
                if (element == null)
                {
                    continue;
                }

                var peer = new ButtonAutomationPeer(element);
                var invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
                if (invokeProv == null)
                {
                    continue;
                }

                invokeProv.Invoke();
                return null;
            }

            throw new AutomationException("No alert is displayed", ResponseStatus.NoAlertOpenError);
        }
All Usage Examples Of System.Windows.Automation.Peers.ButtonAutomationPeer::GetPattern