开发者

how to get the name of an object and change the text of a textbox with its' name?

Hi there (developers of wp7 apps).

The following problem already caused countless sleepless nights, so i hope anyone could provide me with a solution.

Elements grouped as a grid should call (on tap) a function that changes a textbox' text with one i declare.

I already have the function that reads the "name" of the object:

private void FunctionABC(object sender, System.Windows.Input.GestureEventArgs e)
        {
            //Objects name
            string ObjectSender = (sender as Grid).Name.ToString();

            //But how to continue, if I want kind of "this" result?:
            this.ObjectSender.Text = "abc";
        }

I appreciate 开发者_StackOverflow社区any answer my problem. Thanks.


If your question is how to change the textbox.text property which is placed inside a grid if you tap the grid then you should iterate through the grids Children and find the textbox you are looking for and then change it's text property.

First of all you need to change the this line :

string ObjectSender = (sender as Grid).Name.ToString();

because this line gives you the name of the Grid and not the Grid itself.

Grid ObjectSender = (Grid) sender;

And then you can search through it's children.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜