Question

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?

Was it helpful?

Solution

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;
        }

OTHER TIPS

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;
        }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top