title: Is there a way to set the AutomationID of an object without using XAML?
body: <p>I need to automate a Winform application.  How do I set the <code>AutomationID</code> (or <code>AutomationName</code>) like the the XAML in <a href="http://msdn.microsoft.com/en-us/library/windows/apps/xaml/jj150602.aspx" rel="nofollow noreferrer">this article </a> does?</p>
  
  <p>From this <a href="https://stackoverflow.com/questions/9996145/is-there-any-unique-identifier-for-wpf-uielement/10814688#10814688">stack overflow article</a> the answer seems to be no, unless I switch the application to a WPF application (so I can use XAML to define the controls).</p>
  
  <p>I have tried this naïve approach:</p>
  
  <pre><code>  AutomationElement formAutomation = AutomationElement.FromHandle(this.Handle);
    formAutomation.Current.Name = "SandboxResponseDialogName";
    formAutomation.Current.ClassName = "SandboxResponseDialogClassName";
    formAutomation.Current.AutomationId = "SandboxResponseDialogID;
  </code></pre>
  
  <p>But at this point in the constructor for the control, these Automation properties have getters only; no setters.</p>