Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8287841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:09:15+00:00 2026-06-08T12:09:15+00:00

I have a list of AutomationPattern objects retrieved from the AutomationElement.GetSupportedPatterns() method. And now

  • 0

I have a list of AutomationPattern objects retrieved from the AutomationElement.GetSupportedPatterns() method. And now I need to know what kind of patterns are there, I mean is the single item InvokePattern or ExpandCollapsePattern. To be more specific let’s assume we have an AutomationPattern object and we know that the ProgrammaticName property of this object is the “InvokePatternIdentifiers.Pattern” string, can I somehow get object of type InvokePattern?

I have implemented my own way of solving this problem using AutomationPattern.ProgrammaticName property and a big switch statement, is there another way to do this?

Here is my implemetation:

    public object GetActualAutomationPattern(AutomationElement element, AutomationPattern pattern)
    {
        switch (pattern.ProgrammaticName)
        {
            case "DockPatternIdentifiers.Pattern":
                return element.GetCurrentPattern(DockPattern.Pattern) as DockPattern;
            case "ExpandCollapsePatternIdentifiers.Pattern":
                return element.GetCurrentPattern(ExpandCollapsePattern.Pattern) as ExpandCollapsePattern;
            case "GridPatternIdentifiers.Pattern":
                return element.GetCurrentPattern(GridPattern.Pattern) as GridPattern;
            case "GridItemPatternIdentifiers.Pattern":
                return element.GetCurrentPattern(GridItemPattern.Pattern) as GridItemPattern;
            case "InvokePatternIdentifiers.Pattern":
                return element.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern;
            case "MultipleViewPatternIdentifiers.Pattern":
                return element.GetCurrentPattern(MultipleViewPattern.Pattern) as MultipleViewPattern;
            case "RangeValuePatternIdentifiers.Pattern":
                return element.GetCurrentPattern(RangeValuePattern.Pattern) as RangeValuePattern;
            case "ScrollPatternIdentifiers.Pattern":
                return element.GetCurrentPattern(ScrollPattern.Pattern) as ScrollPattern;
            case "ScrollItemPatternIdentifiers.Pattern":
                return element.GetCurrentPattern(ScrollItemPattern.Pattern) as ScrollItemPattern;
            case "SelectionPatternIdentifiers.Pattern":
                return element.GetCurrentPattern(SelectionPattern.Pattern) as SelectionPattern;
            case "SelectionItemPatternIdentifiers.Pattern":
                return element.GetCurrentPattern(SelectionItemPattern.Pattern) as SelectionItemPattern;
            case "TablePatternIdentifiers.Pattern":
                return element.GetCurrentPattern(TablePattern.Pattern) as TablePattern;
            case "TableItemPatternIdentifiers.Pattern":
                return element.GetCurrentPattern(TableItemPattern.Pattern) as TableItemPattern;
            case "TogglePatternIdentifiers.Pattern":
                return element.GetCurrentPattern(TogglePattern.Pattern) as TogglePattern;
            case "TransformPatternIdentifiers.Pattern":
                return element.GetCurrentPattern(TransformPattern.Pattern) as TransformPattern;
            case "ValuePatternIdentifiers.Pattern":
                return element.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern;
            case "WindowPatternIdentifiers.Pattern":
                return element.GetCurrentPattern(WindowPattern.Pattern) as WindowPattern;
            default:
                return pattern;
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T12:09:16+00:00Added an answer on June 8, 2026 at 12:09 pm

    You can just do something like:

    object patternObj = element.TryGetCurrentPattern(pattern);
    

    and then just test whether or not the type is what you want:

    if (patternObj != null && patternObj is InvokePattern) {...} 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have List of User object, I just want to get User objects from
I have list of location address. from my current location, i need to get
I have list of objects which are returned from mvc controller as Json. I'm
I have list of structure. I want to modify a particular data from the
i have list of images and on mouse over there is option box shows
I have list of files which contain particular patterns, but those files have been
I have list of some data items. Each has a method GetStyle which returns
I have list item with EditText in it, I dont know how many items
I have list of data.frames and I wonder whether there is an easy indexing
I have list of items that need to be processed and printed to the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.