So I have a context menu that appears when a user taps and holds on a listbox item. I have this code to get the value from the item that was tapped.
ListBoxItem contextMenuListItem = (ListBoxItem)(myListBox.ItemContainerGenerator.ContainerFromItem(((MenuItem)sender).DataContext));
string item = (contextMenuListItem).Content.ToString();
But the variable “item” now contains the value from the item that was tapped. I want to get the index from the item. Is it possible? And if yes, how?
I am using the context menu from Silverlight’s toolkit.
For my first Windows Phone app (last year) I did something like you and I used MVVM like Shawn Kendrot proposed.
My code is on GitHub. Feel free to have a look even if it’s not an extraordinary application/code.
https://github.com/fabmoll/SimpleTodo