I am actually facing a little issue concerning a LongLingSelector object in C# (WP8).
The string I am working on is the following:
string tmpText = ((Storico)Storico.SelectedItem).Name;
where (Storico) is the class and Storico is the LongListSelector XAML object.
What I currently need is that, when the user presses an item of the list, I subsequentially get its name in the tmpText string.
What I am currently getting, instead, is the following:
let's suppose I have 3 items in my list:
item1
item2
item3
I press item 1, nothing happens. I press item 2, I get item 1 name. I press item 1, I get item 2 name (and that goes on over and over, also with item3 of course).
Any way to fix that?
Thanks in advance!
Full code is here :)
private void Storico_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
if (Storico.SelectedItem is Storico)
{
string tmpText = ((Storico)Storico.SelectedItem).Name;
}
}
Not sure if your project is already using MVVM, but if it does... you can use following Behaviour - http://www.spikie.be/blog/post/2014/01/10/.aspx to get access to the selected item!
A complete explanation on what is 'odd' with the current LongListSelector and how to counter it, can be found on the Nokia Developer site here: http://developer.nokia.com/community/wiki/LongListSelector_with_bindable_SelectedItem_and_better_scrolling
Fixed! I actually was checking the tap event on the Button in the LongListSelector. I changed it to check the LongListSelector, instead, and I got it fixed!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.