c# - Getting the SelectedIndex of a LongListSelector Item -


i have wp8 databound app itemviewmodel bound longlistselector.

quite simply, when user taps on item in list, need retrieve index number of item selected future use. (0 first in list, 1 second, etc.)

so, might retrieve property of selected item:

string whateverproperty = (mylonglistselector.selecteditem itemviewmodel).whateverproperty; 

i need (obviously made code):

int indexnumber = (mylonglistselector.selecteditem itemviewmodel).getselectedindex(); 

i think selectedindex property thing need can't figure out how retrieve it.

thank you!

edit: solved! following gets me looking for:

 int selectedindex = app.viewmodel.items.indexof(mainlonglistselector.selecteditem itemviewmodel); 

i had same problem. need use itemsource retrieve index. should match data template index index.

int selectedindex = selector.itemssource.indexof(selector.selecteditem itemviewmodel); 

selector references longlistselector object sender. hope helps!


Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -