0

I am asking for a user to type in what he or she would like to search for, and then I would like to pass this value to another page where the search will be performed and the results will be given. I am using a PhoneTextBox control from the WP Toolkit. On the KeyUp or ActionIconTapped event I would like to get the value entered in the PhonTextBox and pass that to my search page, although I cannot figure out how to get the text value entered?

MainPage.xaml

<toolkit:PhoneTextBox x:Name="publicSearchTextBox" HorizontalAlignment="Stretch" Margin="-10,0,12,0"
                      Hint="search for topic or name"
                      ActionIcon="/Resources/Images/search.png" 
                      ActionIconTapped="publicSearchTextBox_ActionIconTapped"
                      KeyUp="publicSearchTextBox_KeyUp"/>

MainPage.xaml.cs

..get publicSearchTextBox text value and pass this to the search page?

For some reason, I cannot reference the PhoneTextBox in my code behind from setting x:Name="publicSearchTextBox" in my xaml? How is this possible?

Mark Hall
  • 53,938
  • 9
  • 94
  • 111
Matthew
  • 3,976
  • 15
  • 66
  • 130

1 Answers1

0

Perhaps you have a typo because i made some handlers for the XAML you have above and it works fine for me. Copy paste the following in the code behind and try?

private void PrintTextboxValue()
{
    Debug.WriteLine("Value: {0}", publicSearchTextBox.Text);
}

private void publicSearchTextBox_ActionIconTapped(object sender, EventArgs e)
{
    PrintTextboxValue();
}

private void publicSearchTextBox_KeyUp(object sender, KeyEventArgs e)
{
    PrintTextboxValue();
}

If it does not work then please update your question with more information such as, where you are referencing the PhoneTextBox.

Gros Lalo
  • 1,078
  • 7
  • 20