silverlight模拟单击事件

public static class ButtonBaseExtensions
{
/// <summary>
/// 模拟单击事件
/// </summary>
/// <param name="button"></param>
public static void PerformClick(this System.Windows.Controls.HyperlinkButton button)
{
System.Windows.Automation.Peers.HyperlinkButtonAutomationPeer buttonPeer = new System.Windows.Automation.Peers.HyperlinkButtonAutomationPeer(button);
System.Windows.Automation.Provider.IInvokeProvider invokeProvider = buttonPeer.GetPattern(System.Windows.Automation.Peers.PatternInterface.Invoke) as System.Windows.Automation.Provider.IInvokeProvider;
invokeProvider.Invoke();
}
}

posted @ 2013-03-05 17:06  狄大人  阅读(345)  评论(0编辑  收藏  举报