Search code examples
c#visual-studio-2012windows-8windows-store-appsmouseclick-event

Textbox tapped event don't fire on windows 8 for mouse click


I have the following code that builds me a text box. The application requires me to make all my controls generic, as that is the way our api is sending it to us.

TextBox txtcontent = new TextBox();
txtcontent.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch;
txtcontent.SetValue(Grid.ColumnProperty, 1);
txtcontent.SetValue(Grid.RowProperty, RowCount);
txtcontent.Width = 320;
txtcontent.FontSize = 20;
txtcontent.TextWrapping = TextWrapping.Wrap;
txtcontent.Margin = new Thickness(10);
txtcontent.Foreground = App.scbAccTechGrayDark;
txtcontent.BorderBrush = App.scbAccTechGrayLight;
txtcontent.Background = App.scbAccTechGreenLight;
txtcontent.Tapped += txtcontent_Tapped;

Now the problem is when I click on the textbox it does not fire the tapped event. I understand that the mouse click will fire the tapped event for a store app?

Here is 1st part of the tapped event, but I never reach it.

void txtcontent_Tapped(object sender, TappedRoutedEventArgs e)
{
    TextBox txtFinder = (sender as TextBox);
    string[] myconver = (sender as TextBox).Tag.ToString().Split(',');
    int BlockIndex = Convert.ToInt16(myconver[4].ToString());
    int FieldID = Convert.ToInt16(myconver[5].ToString());
    string ColumnName = Convert.ToString(myconver[6].ToString());
    string FieldCode = Convert.ToString(myconver[7]);
    string BlockName = Convert.ToString(myconver[8]);
}

Can anyone please tell me what i must do, or what i am doing wrong here?


Solution

  • You want to use the GotFocus event of the TextBox control.