OknAkdgn
OknAkdgn

Reputation: 41

I want to get name of focused textbox controls that I created at run-time in WP 8.1

I am adding got focus event mytextboxes when I create them

                `TextBox Xi = new TextBox();
                Xi.Name = "X" + i.ToString();
                Xi.Width = 10;
                Xi.Height = 10;
                Xi.GotFocus += Xi_GotFocus;`

But I can't get focused control's name

void Xi_GotFocus(object sender, RoutedEventArgs e) { throw new NotImplementedException(); }

is there any way get the name of these controls ? Thank you

Upvotes: 0

Views: 406

Answers (1)

Dhaval Patel
Dhaval Patel

Reputation: 7591

you can use below mentioned code

void Xi_GotFocus(object sender, RoutedEventArgs e)
{ 
    TextBox t = sender as TextBox;
    string name = t.Name;
}

Upvotes: 1

Related Questions