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

  • SEARCH
  • Home
  • 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 8095525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:09:36+00:00 2026-06-05T21:09:36+00:00

The GetPattern() method implementation of WPF UI Automation system is implemented taking the enum

  • 0

The GetPattern() method implementation of WPF UI Automation system is implemented taking the enum parameter PatternInterface and we normally use it in the following way:

//Code with original implementation
ButtonAutomationPeer buttonPeer = new ButtonAutomationPeer(button1);
IInvokeProvider provider = (IInvokeProvider)buttonPeer.GetPattern(PatternInterface.Invoke); //Line in Question
//To invoke the click event of button we then use the following code:
provider.Invoke();

From the above code, it seems that the line with comment Line in Question is not strongly typed, we need to cast the return from GetPattern() method to the required interface and then use it to invoke the specific UI automations.

Question is:
Would it not have been better if the implementation of the GetPattern() method in WPF was done using already present Generics in .Net Framework as below:

public T GetPattern<T>;
  • where, I would then pass the required interface pattern name while
    calling the GetPattern<T> method and get that interface instance
    strongly typed and would also not need a cast. What
    thought has Microsoft given in the original implementation of
    GetPattern() method requiring an enum?
  • Would using enums in the method parameters not break the
    maintainability of the GetPattern() original implementation. I
    would say that when a new Control interface pattern is needed to be
    supported, that pattern interface’s enum value would need to be
    added to the enum parameter named PatternInterface

I suppose it is easier and better to call the method and get the interface pattern using the below new code that uses calling the Generic implementation:

//Code with New Generics based implementation
ButtonAutomationPeer buttonPeer = new ButtonAutomationPeer(button1);
IInvokeProvider provider = buttonPeer.GetPattern<IInvokeProvider>(); //Line in Question
//To invoke the click event of button we then use the following code:
provider.Invoke();
  • 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-05T21:09:38+00:00Added an answer on June 5, 2026 at 9:09 pm

    It is for the usual reason: they didn’t have a time machine. Visible from the “History” annotations in the source code files available from the Reference Source, work on the UI Automation classes started around June 2003 with evidence that it got derived from earlier work. Generics didn’t become available until 2005.

    From dd/wpf/src/UIAutomation/UIAutomationTypes/System/Windows/AutomationPattern.cs:

    // History:
    //  06/02/2003 : BrendanM Ported to WCP
    

    Which was very likely Brendan McKeon. No decent guess at what “WCP” might have meant.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to get pattern matching to match my value with any
is there any way to translate rich calendar to language which is not supported
I implemented the Post-Redirect-Get pattern to avoid the problem where a refresh of a
I have some forms, and am currently using an implementation as described below: <form
I'm looking at adding some basic search and filtering functionality in a generic/standardized way
We began a project using WebForms, and developed a somewhat complex portal system to
I'm using the Post/Redirect/Get pattern on a form of mine. I've never used this
struct GPattern() { int gid; .... } class Example() { public: void run(string _filename,
I am traying to get log4j to log to file in XMLLayout using the
I still am confused regarding Ajax technology. And I still cannot answer this question

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.