Create a grid in WPF as Template programmatically

前端 未结 4 1881
太阳男子
太阳男子 2021-01-17 13:59

I want to create a basic user control with a style programmatically. In this style I want to add a Grid (no problem), but I can\'t add column definitions to thi

4条回答
  •  逝去的感伤
    2021-01-17 14:48

    You just need to change the last part of your code. See below,

    Original Code:

            colDefinitions.AppendChild(c1);
            colDefinitions.AppendChild(c2);
            colDefinitions.AppendChild(c3);
            mainGrid.AppendChild(colDefinitions);
    

    New Code:

            mainGrid.AppendChild(c1);
            mainGrid.AppendChild(c2);
            mainGrid.AppendChild(c3);
    

提交回复
热议问题