Monday, October 14, 2013

How to Add Tapped Event to the Textbox in Windows 8 Application.

Over the forum discussion, some one asked an question “Tapped Event” is not occurring/firing in his application, so I have decided to write a quick code snippet for the same solution.

I did quick work around and added AddHandler() method. And it adds a routed event handler for a specified routed event.


See the following code snippet:


txtMyTextBox.AddHandler(TappedEvent, new TappedEventHandler(txtMyTextBox_Tapped), true);

void txtMyTextBox_Tapped(object sender, TappedRoutedEventArgs e)
        {
            MessageDialog msgDialog = new MessageDialog("Tapped Event occour", "Windows 8 App");

            //OK Button
            UICommand okBtn = new UICommand("OK");
            okBtn.Invoked = OkBtnClick;
            msgDialog.Commands.Add(okBtn);

            //Cancel Button
            UICommand cancelBtn = new UICommand("Cancel");
            cancelBtn.Invoked = CancelBtnClick;
            msgDialog.Commands.Add(cancelBtn);

            //Show message
            msgDialog.ShowAsync();
        }


Here is a completed source code.


Hope it will help, Happy Coding.

3 comments:

Mike J. Cantero said...

A Tapped event speaks to a motion, while a Pointerpressed event is a lower-level info event. Tapped and Pointerpressed events could be raised as the consequence of a single user association. On the off chance that the event source has a nondefault Manipulationmode, Manipulationstarting could be raised as well. Regardless of the possibility that a control is as of now taking care of Pointerpressed in the control rationale, or is taking care of controls, that doesn't prevent Tapped from being raised.

Click here

Aditya Manjrekar said...

Make free apps and games on Windows Phone.
http://windowsphone-9.blogspot.com/2014/08/how-to-make-free-license-applications.html

Sarah Taylor said...

You have explained very briefly and positively .how to Add Tapped Event to the Textbox in Windows 8 Application. It would be helpful for windows app development