button1.PerformClick() in wpf

后端 未结 7 1643
难免孤独
难免孤独 2020-12-15 21:07

Why this code in WPF does not work ?

private void button1_Click(object sender, EventArgs e)
    {
        MessageBox.Show(\"yes\");
    }
    pr         


        
7条回答
  •  情话喂你
    2020-12-15 22:00

    An excerpt from Adam Nathans WPF Unleashed, recommended by this blog.
    Imho one of the best, if not the best WPF references around.

    var bap = new System.Windows.Automation.Peers.ButtonAutomationPeer(someButton);
    var iip = bap.GetPattern(System.Windows.Automation.Peers.PatternInterface.Invoke)  
                                as System.Windows.Automation.Provider.IInvokeProvider;
    iip.Invoke();
    

提交回复
热议问题