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, newTappedEventHandler(txtMyTextBox_Tapped), true);
void txtMyTextBox_Tapped(object sender, TappedRoutedEventArgs e)
        {
            MessageDialog msgDialog = newMessageDialog(“Tapped Event occour”, “Windows 8 App”);
            //OK Button
            UICommand okBtn = newUICommand(“OK”);
            okBtn.Invoked = OkBtnClick;
            msgDialog.Commands.Add(okBtn);
            //Cancel Button
            UICommand cancelBtn = newUICommand(“Cancel”);
            cancelBtn.Invoked = CancelBtnClick;
            msgDialog.Commands.Add(cancelBtn);
            //Show message
            msgDialog.ShowAsync();
        }
Here is a completed source code.
Hope it will help, Happy Coding.
Advertisements

About Pavan Pareta

My name is Pavan Pareta, I enjoy computers and general technology. I am more interested in the areas of Computer Security, Programming and developing innovative s/w for Windows Mobile and Windows Phone 7. I like MS Technology and support open-source software, because I believe it plays a major role in knowledge sharing and exchange of ideas, which effectively leads to better software. Additionally, I am a follower of the KISS (Keep It Simple Stupid) philosophy. I Love C#.NET and recently I am fall in love with Silverlight :) Introduce to my machine My main workstation is a Intel Pentium Core Duo and my primary operating system is Windows 7.
This entry was posted in Windows 8. Bookmark the permalink.

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

  1. Vijay Nath says:

    This comment has been removed by a blog administrator.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s