C# 如何从Windows Phone 8中的长列表选择器项中获取文本?

C# 如何从Windows Phone 8中的长列表选择器项中获取文本?,c#,windows-phone-7,windows-phone-8,longlistselector,C#,Windows Phone 7,Windows Phone 8,Longlistselector,我有一个动态填充的长列表选择器,这意味着用户在其中添加项目。 这是添加项目的方式 source.Add(new ShoppingList(Item1.Text)); Item1是一个文本框,用户通过它向列表中添加内容 我有一个长长的列表选择器。让我们称之为LLS。我希望当点击某个itam时,项目中的文本被复制并粘贴到文本块中 到目前为止,我尝试了以下方法: string item = LLS.SelectedItems.ToString(); TextBlock.Text = item;

我有一个动态填充的长列表选择器,这意味着用户在其中添加项目。
这是添加项目的方式

source.Add(new ShoppingList(Item1.Text));
Item1是一个文本框,用户通过它向列表中添加内容

我有一个长长的列表选择器。让我们称之为LLS。我希望当点击某个itam时,项目中的文本被复制并粘贴到文本块中

到目前为止,我尝试了以下方法:

string item = LLS.SelectedItems.ToString();  TextBlock.Text = item;
如何做到这一点?
感谢您的关注和解答。

您必须订阅SelectionChanged事件:

ShoppingList sitem = LLS.SelectedItem as ShoppingList;
string item = string.empty;
if ( sitem != null )
{
 item = sitem. (property where you text is stored)
}
private void LLS_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
  if (LLS.SelectedItem != null)
  {
     ShoppingList item = LLS.SelectedItem as ShoppingList;
     TextBlock.Text = item.yourProperty;
  }
}

顺便说一句,已经有类似的问题了:,可能还有更多。

对不起,我是编程方面的一个新手,那么“yourProperty”ShoppingList是什么意思呢?ShoppingList是你的类,yourProperty是指保存文本的变量/属性。运行new ShoppingList(item.text)时-这是存储item.text的变量的名称。