I am trying to create a Button in Windows phone 7 without making use of the .xaml file. I was able to create a button programmatically as follows :
Button btn = new Button() { Content = "Button" };
btn.Width = 148;
btn.Height = 148;
Thickness margin = new Thickness(x, y, x1, 400);
btn.Margin = margin;
This works fine. But how do I listen to the click event of this button. If it was created using the .xaml file, the listener function would have been created automatically when double-clicked on the button in the preview window. How can I create it in this case.
Be advised, I am a newbie in WP7 programming. Thanks!
btn.Click +=
... (after the += you can push tab twice to add an event handler).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With