开发者

Cannot implicitly convert type 'MouseEventHandler' to 'RoutedEventHandler

I tried to inherit method button1_click and I got the message above, how to fix that ?

namespace visualinheritance
{
    public partial class usercontrolcommon : UserControl
    {
        public usercontrolcommon()
        {
            InitializeComponent();
        }

        public void button1_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("usercontrolcommon");
        }
    }
}

namespace visualinheritance
{
    public partial class usercontrol1 : usercontrolcommon
    {
        public usercontrol1()
        {
            InitializeComponent(开发者_Go百科);
            this.button1.Click += new MouseEventHandler(button1_Click);

        }

    }
}


The button click event is not a mouse event. Just change the handler to button1.Click += button1_Click; and it will work

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜