0

在 Visual Studio 2010 中,我习惯于通过智能感知进行手动事件绑定,如下所示,new EventHander我的所有事件名称都有包装器。

public partial class NiftyUserControl : System.Web.UI.UserControl
{
    public NiftyUserControl()
    {
        //Bind usercontrol 'page' events
        this.Init += new EventHandler(NiftyUserControl_Init);
    }

    void NiftyUserControl_Init(object sender, EventArgs e)
    {
        //Bind usercontrol children events
        cmdBestButtonEver.Command += new CommandEventHandler(cmdBestButtonEver_Click);
    }

    void cmdBestButtonEver_Click(object sender, CommandEventArgs e)
    {
        //Perform Best Magic Ever
    }
}

我安装了新的 Visual Studio 2012 Web Express,现在我的事件创建过程最终如下所示:

public partial class GreatSadness : System.Web.UI.UserControl
{
    public GreatSadness()
    {
        //Bind usercontrol 'page' events
        this.Init += GreatSadness_Init;
    }

    void GreatSadness_Init(object sender, EventArgs e)
    {
        //Bind usercontrol children events
        cmdVerySadButton.Command += cmdVerySadButton_Command;
    }

    void cmdVerySadButton_Command(object sender, CommandEventArgs e)
    {
        // =(
    }
}

这对我的气有负面影响。如何告诉 Visual Studio 2012 创建看起来像最顶层示例的事件绑定?

4

0 回答 0