How to change the Grid.Row and Grid.Column of the control from code behind in wpf

前端 未结 2 1933
后悔当初
后悔当初 2021-02-06 21:41

I have the control placed in DataGrid like this:

相关标签:
2条回答
  • 2021-02-06 21:59

    There is also a static method to do this (analogous to using the property in code to set a non-attached property rather than using the DP there).

    Grid.SetRow(txtDescription, 1);
    

    You may find this more readable.

    0 讨论(0)
  • 2021-02-06 22:12

    Use DependencyObject.SetValue, passing in the DependencyProperty for Grid.Row and the value you want to assign:

    this.txtDescription.SetValue(Grid.RowProperty, 1);
    
    0 讨论(0)
提交回复
热议问题