如何控制的网格行从代码改变落后于WPF [英] how to change the grid row of the control from code behind in wpf

查看:101
本文介绍了如何控制的网格行从代码改变落后于WPF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来WPF。目前我有以下

I am new to wpf . Presently i have the control palced in datagrid like below

    <Label Name="lblDescription"    HorizontalAlignment="Left" Margin="0,5,0,0" Grid.Row="2" Grid.Column="2" />

<TextBox  Name="txtDescription" HorizontalAlignment="Left"  Width="200"  Margin="0,5,0,0" TextWrapping="Wrap"  VerticalScrollBarVisibility="Visible" AcceptsReturn="True"  Grid.RowSpan="2" Grid.Row="2" Grid.Column="3" />

现在我想改变控件的网格行和列在后面的代码。我怎样才能做到这一点。

Now i want to change the grid row and column of the control in code behind . How can i do this.

推荐答案

有也是这样做(类似于在代码中使用属性来设置一个静态方法。无附加属性,而不是使用DP那里)

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.

这篇关于如何控制的网格行从代码改变落后于WPF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆