using System.Windows;
using System.Windows.Controls;using Microsoft.Phone.Controls;namespace _3._1
{ public partial class MainPage : PhoneApplicationPage { // Constructor public MainPage() { InitializeComponent(); }private void button1_Click(object sender, RoutedEventArgs e)
{ Button mynewbutton = new Button(); mynewbutton.Name = "button2"; mynewbutton.Content = "Click Me"; mynewbutton.Height = 100; mynewbutton.Width = 200; mynewbutton.Margin = new Thickness(100.0, 100.0, 100.0, 100.0); mynewbutton.HorizontalAlignment = HorizontalAlignment.Stretch; mynewbutton.VerticalAlignment = VerticalAlignment.Stretch;ContentGrid.Children.Add(mynewbutton); //ContentGrid是xaml页面里的Grid的名字name
}
}}