1

how do I get item on listbox hold event in windows phone? suppose I have three items in listbox,

1 - abc
2 - def
3 - ghi

If I hold on item "abc" then how do I get that item?

Viraj Shah
  • 308
  • 1
  • 12
  • 1
    Try to use search option first: [one](http://stackoverflow.com/questions/8269244/how-to-implement-hold-in-listbox), [two](http://stackoverflow.com/questions/21173769/get-selected-item-from-windows-phone-listbox-in-hold-event) and more. – Romasz Apr 03 '14 at 05:38
  • @Viraj Shah could you share your listbox – Jaihind Apr 03 '14 at 06:37

2 Answers2

3

This would help you to get list item on hold event:

private void lst_Hold_1(object sender, System.Windows.Input.GestureEventArgs e)
        {       
            string text = (e.OriginalSource as TextBlock).Text;
        }
Pradeep Kesharwani
  • 1,480
  • 1
  • 12
  • 21
3

May be this helps you.

<ListBox x:Name="lstBoxTemp" Hold="lstBoxTemp_Hold">
  <ListBox.ItemTemplate>
   <DataTemplate>
    <StackPanel>
     .......
     ........
     Your template
    </StackPanel>
   </DataTemplate>
 </ListBox.ItemTemplate>
</ListBox>

private void lstBoxTemp_Hold(object sender, System.Windows.Input.GestureEventArgs e)
        {
         var item= (Cast as YourType)(sender as ListBox).DataContext;
        }
Jaihind
  • 2,770
  • 1
  • 12
  • 19