Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable touch selection in listbox item in Windows Phone 7?

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.

like image 828
user403015 Avatar asked Dec 21 '22 21:12

user403015


2 Answers

Use ItemsControl wrapped in a ScrollViewer. This will give you the same effect without selection (and will allow you to scroll just like a ListBox does)

<ScrollViewer>
  <ItemsControl>
     <ItemsControl.ItemTemplate>
       <DataTemplate>
      ...
       </DataTemplate>
    </ItemsControl.ItemTemplate>
  </ItemsControl>
</ScrollViewer>
like image 27
TechnoTim Avatar answered Jan 25 '23 22:01

TechnoTim


You could use the ItemsControl instead of ListBox. ItemsControl is like ListBox, but it comes without the selection stuff.

<ItemsControl>
   <ItemsControl.ItemTemplate>
      <DataTemplate>
      ...
      </DataTemplate>
   </ItemsControl.ItemTemplate>
</ItemsControl>
like image 156
Fredrik Stolpe Avatar answered Jan 26 '23 00:01

Fredrik Stolpe