Cannot implicitly convert type 'System.EventHandler' to 'System.Windows.RoutedEventHandler' in c#
c#, windows-phone-8
Solution
The signature of your event handler is wrong.
It should be:
private void btn_Click(object sender, RoutedEventArgs e)
And the `Click` event assignment should be changed to:
btn.Click += new RoutedEventHandler(btn_Click);//Click event
Problem
In windows phone application I want to add a button dynamically like below: ``` Button btn = new Button(); btn.Content = tb_groupname.Text; btn.Width = 200; btn.Height = 200; btn.Click += new EventHandler(btn_Click);//Click event ``` But when I add click event on my button I am getting below error: ``` Cannot implicitly convert type 'System.EventHandler' to 'System.Windows.RoutedEventHandler' ``` And below is the click event method of button: ``` private void btn_Click(object sender, EventArgs e) { textbox1.text = "ABC"; // For Example } ``` I don't understand why its getting this error. Kindly suggest me, waiting for reply. Thanks.