开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜