简体   繁体   English

以编程方式将UserControl放置在网格中

[英]Position UserControl in Grid Programmatically

I'm loading UserControls from external dll's. 我正在从外部dll加载UserControls。 My MainWindow contains a Grid and everything is placed within the grid. 我的MainWindow包含一个网格,所有内容都放置在网格内。

How to a position the UserControl in the Grid from codebehind? 如何从代码后面在网格中放置UserControl?

Here is how i'm adding the control currently. 这是我当前添加控件的方式。

UserControl ucSupportButton = 
    new Bootstrapper().LoadUserControl("SC.Support.dll", "Button");
MainGrid.Children.Add(ucSupportButton );

If you want to specify value for Grid.Column and/or Grid.Row attached properties you can use Grid static methods: 如果要为Grid.Column和/或Grid.Row附加属性指定值, Grid.Column可以使用Grid静态方法:

Grid.SetRow(ucSupportButton, 1);
Grid.SetColumn(ucSupportButton , 1);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM