WPF-后台动态创建窗口添加控件示例

            Window window1 = new Window();
            window1.Title = "新窗口";
            window1.Background = Brushes.LightBlue;  // SolidColorBrush brush1 = new SolidColorBrush(Colors.Yellow);

            Grid grid = new Grid();
            Label label1 = new Label();
            label1.Content = "执笔小白";
            label1.FontSize = 20;
            label1.Foreground = Brushes.Red;
            grid.Children.Add(label1);
            window1.Content = grid;

            window1.Show();

 

posted @   ꧁执笔小白꧂  阅读(257)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
历史上的今天:
2021-10-25 Win定时任务未正常运行的bug(win Server2019)
点击右上角即可分享
微信分享提示