wpf动态创建控件后 指定到容器的具体位置
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("我是动态加载出来的呢");
}