tags:

views:

213

answers:

2

Just for kicks I'm playing around a bit with C# and WPF. I'm going through some examples on sending a button click event to a button programmatically since Button.PerformClick() is no longer present. The example I'm following is using the IInvokeProvider from the System.Windows.Automation.Provider namespace. My copy of VisualStudio 2008 Pro can't seem to find said namespace, or the IInvokeProvider interface ANYWHERE! I've looked in the MSDN Documentation, and this is the correct namesapce, and it says it's available on Windows XP and above. What am I doing wrong?

I started the project as a C# WPF Windows Application using the .NET Framework version 3.5.

+1  A: 

Add a reference to UIAutomationProvider.dll... That should allow you to use the System.Windows.Automation.Provider namespace.

Jim H.
Thank you! I'm a C#/.NET newb :)
Grant Limberg
A: 

Try this:

ButtonAutomationPeer bap = new ButtonAutomationPeer(myButton); IInvokeProvider iip = bap.GetPattern(PatternInterface.Invoke) as IInvokeProvider; iip.Invoke(); // This clicks the Button