使用代码创建grid容器

//生成容器
            Grid oneShoot = new Grid();
            oneShoot.Width = user_comment.Width + 100;
            oneShoot.Height = 100 - randomSize*5;

            //定义容器布局
            ColumnDefinition firstColumnDefinition1 = new ColumnDefinition();
            firstColumnDefinition1.Width = new GridLength(avatar.Width, GridUnitType.Pixel);
            oneShoot.ColumnDefinitions.Add(firstColumnDefinition1);

            ColumnDefinition firstColumnDefinition2 = new ColumnDefinition();
            firstColumnDefinition2.Width = new GridLength(user_comment.Width, GridUnitType.Pixel);
            oneShoot.ColumnDefinitions.Add(firstColumnDefinition2);

            

            Grid.SetColumn(avatar, 0);
            oneShoot.Children.Add(avatar);
            Grid.SetColumn(user_comment, 1);
            oneShoot.Children.Add(user_comment);