简体   繁体   中英

How to add Click event handler to TextBlock on Window phones

I am writing a application for c# on windows phones. I create a TextBlock in my page using xaml. How can I add click event handler in xaml. I tried using 'Click' as attribute, but that is not a valid attribute for TextBlock.

Thank you.

It's the Tapped event (Sopuli was almost right). Just a tip for you: on the right hand side of the window is the property explorer. If you click on the event icon on the upper right you will get a list of all events the control exposes.

Just double click inside one of the fields next to the text and the Visual Studio will create the event for you and put a handler in the code behind file.

事件处理程序

Correct, a TextBlock does not have a Click event. However, if you go to the Object Browser and search for TextBlock, you may find an alternative event.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM