开发者

If I have a reference to a button how can I programatically fire the click event?

开发者 https://www.devze.com 2023-03-17 23:59 出处:网络
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.

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();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消