How to add the click event on textblock of listbox?

You can wrap the TextBlock with a Grid, and give it a Transparent color. Then you attach a NavigateToPageAction to the Grid, something like this.

Up vote 0 down vote favorite share g+ share fb share tw.

I am developing window phone 7 application. I have a listbox in my application. I am doing dynamic binding with that listbox.

The code of listbox is as follows This listbox is inside the pivot control. I want to add the link or click event one the following textblock. So that after clicking on the CompanyORIndividual textblock the user should be naviaged to the other xaml page.

How to do this. Can you please provide me the code with the event handler? Can you please provide me nay code or link through which I can resolve the above issue?

If I am doing anything wrong then please gide me. If there is any better idea than my above question then please suggest it data-binding windows-phone-7 listbox onclick textblock link|improve this question asked Apr 29 '11 at 14:04Shailesh Jaiswal8061032 89% accept rate.

That could lead to issues with the gestures on the listbox getting misinterpreted as a gesture on the pivot item and vice versa. This is something that is generally not recommended and you should test this thoroughly with actual users. – Matt Lacey Apr 29 '11 at 17:58.

You can wrap the TextBlock with a Grid, and give it a Transparent color. Then you attach a NavigateToPageAction to the Grid, something like this, xmlns:Custom="clr-namespace:System.Windows. Interactivity;assembly=System.Windows.

Interactivity" xmlns:ic="clr-namespace:Microsoft.Expression.Interactivity. Core;assembly=Microsoft.Expression. Interactions" The reason that you need to give the Grid a color is because doing so will be able to receive mouse click.

Please give it a try and let me know if you have problems using it. Alternatively, you can wrap the TextBlock with a Button, then handle the Button's click event. Update: Matt is right about the thing that using MouseLeftButtonDown/MouseLeftButtonUp may sometimes be bad.

In my own project I have created a simple style for a button which acts like a clickable TextBlock. Also another good thing of using a button is it can receive the TiltEffect and allow Commanding.

I'd recommend using a Tap gesture (from the Silverlight Toolkit) on the TextBlock. This will avoid issues with incorrectly detecting mousebutton up or down events when the user is scrolling the listbox. In my opinion this also provides a better user experience than detecting SelectedItem changed on the Listbox.

1, I think your right about it, I will update my answer to use a button instead. A tap and a button click should work the same way right? – Xin May 1 '11 at 7:56.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions