views:

20

answers:

1

Hi,

In the XAML template, I used a listbox to populate some dynamic data.

Now I want to disable touch selection in certain listbox items in Windows Phone 7. How to do that ?

I had done some little research, some people said that the selection event could be prevented in the listbox.

http://social.msdn.microsoft.com/forums/en-US/wpf/thread/8eeed347-ede5-4a24-88f1-953acd16e774

Hope some smart guys could teach me how to solve the problem.

Thanks.

A: 

Try using a variable to store the last selected index.

If the user then selects an item which you don't want to handle the selection event for then set the selected index back to the stored value. If you do want to hand;e the selection changed event then be sure to update your stored value too.

You'll probably also want to avoid triggering the selection changed when you manually set the index (back).
A simple boolean flag could be used to track this.

Matt Lacey