简体   繁体   中英

Position UserControl in Grid Programmatically

I'm loading UserControls from external dll's. My MainWindow contains a Grid and everything is placed within the grid.

How to a position the UserControl in the Grid from codebehind?

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.SetRow(ucSupportButton, 1);
Grid.SetColumn(ucSupportButton , 1);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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