WPF - 在代码隐藏中更改网格中控件的位置

Joh*_*tål 2 wpf-controls

是否可以通过代码隐藏更改控件放置在网格中的位置?

例如,如果我在Grid.Row ="1"中有一个Button,我可以从代码隐藏中将其更改为Grid.Row ="0"吗?

Gob*_*lin 5

是.去吧:

Grid.SetRow(button,0);
Run Code Online (Sandbox Code Playgroud)

其中button是要更改的元素.