private void Window_Loaded(object sender, RoutedEventArgs e)
{
Button button5 = new Button();
button5.Click += Button5_Click;
button5.Height = 50;
button5.Width = 50;
button5.Name = "Button6";
button5.Content = "動態狗";
grid1.Children.Add(button5);
button5.SetValue(Grid.RowProperty, 2);//設置到Grid對應的行
button5.SetValue(Grid.ColumnProperty, 2);//設置到Grid對應列
}
private void Button5_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("我是動態加載出來的呢");
}