1
votes

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.

2

2 Answers

2
votes
ShoppingList sitem = LLS.SelectedItem as ShoppingList;
string item = string.empty;
if ( sitem != null )
{
 item = sitem. (property where you text is stored)
}
1
votes

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.