0

I am new in wpf, so i have a problem in my gridview.

I'm using a TextBox in the GridView . Basically, what I want to do is call a method every time the text in the box is edited. That is when the text is entered, the function will call. That is the text change event should work.

Jinesh
  • 1,480
  • 2
  • 25
  • 52

1 Answers1

1

Use the TextChanged event.

.xaml:

<TextBox TextChanged="TextBox_TextChanged" ... />

.xaml.cs:

private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
    string text = ((TextBox)sender).Text;
    // call your function
}
jnovo
  • 5,659
  • 2
  • 38
  • 56
  • my text box is in the gridview.So how can i get the current value of this textbox? – Jinesh Feb 03 '14 at 11:07
  • Then, you'll need to modify the cell template so you can set the event. Check this answer: http://stackoverflow.com/a/4725474/3042204 – jnovo Feb 03 '14 at 11:14
  • i do the same, but how can i get the value in that text box? – Jinesh Feb 03 '14 at 11:26
  • 1
    @JineshG check the edit, you just need to cast the `sender` to `TextBox` and get the text – jnovo Feb 03 '14 at 11:32