使用代码创建WPF文字

//动态生成文字
            TextBox user_comment = new TextBox();
            user_comment.FontSize = 36 - randomSize;
            user_comment.Height = 60 - randomSize;
            user_comment.Width = (text.Length * user_comment.FontSize) + randomWidth;
            //user_comment.Effect = new System.Windows.Media.Effects.DropShadowEffect();

            user_comment.Foreground = new SolidColorBrush(Colors.White);
            if (randomColor == 1)
            {
                user_comment.Foreground = new SolidColorBrush(Color.FromArgb(255, 254, 241, 2));
            }
            if (randomColor == 2)
            {
                user_comment.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));
            }
            if (randomColor == 3)
            {
                user_comment.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 102, 255));
            }
            if (randomColor == 4)
            {
                user_comment.Foreground = new SolidColorBrush(Color.FromArgb(255, 226, 2, 127));
            }
            if (randomColor == 5)
            {
                user_comment.Foreground = new SolidColorBrush(Color.FromArgb(255, 231, 0, 18));
            }
            if (randomColor == 6)
            {
                user_comment.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 242, 1));
            }
            user_comment.Text = text;