WPF Grid 的自适应布局

文章目录

    一个不错的教程

    图文并茂

    https://www.c-sharpcorner.com/UploadFile/1e050f/grid-layout-in-wpf/

    比官方文档好太多了。看上去作者像是印度人,这种文章能有 52 万的阅读量,确实非常惊人。

    代码创建 Grid

    https://learn.microsoft.com/en-us/dotnet/desktop/wpf/controls/how-to-create-a-grid-element?view=netframeworkdesktop-4.8

    没想到用 CSharp 代码实现 Grid 看起来可读性也不错。对于动态显示的使用场景,可能比 XAML 更灵活。

    // Create the application's main window
    mainWindow = new Window();
    mainWindow.Title = "Grid Sample";
    
    // Create the Grid
    Grid myGrid = new Grid();
    myGrid.Width = 250;
    myGrid.Height = 100;
    // ...
    
    // Add the Grid as the Content of the Parent Window Object
    mainWindow.Content = myGrid;
    mainWindow.Show ();
    

    关于作者 🌱

    我是来自山东烟台的一名开发者,有感兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊,或者关注我的个人公众号“大象工具”, 查看更多联系方式