ShoppingList sitem = LLS.SelectedItem as ShoppingList;
string item = string.empty;
if ( sitem != null )
{
item = sitem. (property where you text is stored)
}
How to get text from long list selector item in Windows Phone 8?
-
24-09-2022 - |
Question
I have a long list selector that is populated dynamically meaning the user adds items there.
This is the way items are added.
source.Add(new ShoppingList(Item1.Text));
Item1 is a textbox via which user adds stuff to the list.
I have a long list selector. Let's call it LLS. I want that when a certain itam is tapped, the text within the item is copied and pasted into a textblock.
So far I have tried the following:
string item = LLS.SelectedItems.ToString(); TextBlock.Text = item;
How can this be achieved? Thank You for your attention and answers.
Solution
OTHER TIPS
You have to subscribe to SelectionChanged Event:
private void LLS_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (LLS.SelectedItem != null)
{
ShoppingList item = LLS.SelectedItem as ShoppingList;
TextBlock.Text = item.yourProperty;
}
}
BTW - there are already similar questions: one, two and probably more.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow