If I have a reference to a button how can I programatically fire the click event?
Through the infrastructure we've built, there is a command attached to开发者_开发知识库 a button, and through it's event handler, we get a reference to the button.
So, given that I have a reference to the button, how do I fire the click event?
How about this article (relates to SLv2)? Or this SO answer (related to SLv3)? And finally, another SO answer (for SLv4)?
if (button is Button)
{
ButtonAutomationPeer peer = new ButtonAutomationPeer((Button)button);
IInvokeProvider ip = (IInvokeProvider)peer;
ip.Invoke();
}
精彩评论