http://joshsmithonwpf.wordpress.com/2007/03/09/how-to-programmatically-click-a-button/
Back in WinForms it was really easy to simulate a userclicking a Button, you just call a Button’s PerformClick method. For somereason the WPF Button does not have that method. It turns out that youneed to enter into the automation world to accomplish this task.
WPF takes a slighly different approach than WinForms here.Instead of having the automation of an object built into the API, they have aseparate class for each object that is responsible for automating it. In thiscase you need the ButtonAutomationPeer to accomplish this task.
ButtonAutomationPeer peer = new ButtonAutomationPeer(someButton );
IInvokeProviderinvokeProv = peer.GetPattern( PatternInterface.Invoke ) as IInvokeProvider;
invokeProv.Invoke();
The UIAutomation*.dll is located in this folder:
C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0
If you can't find in your Add Reference->.Net tab, then you have to use the Browse tabto go to the given path, and add the assembly (Right Click on the References, choose add reference, clickbrowse tab):
Other reference in Chinese: