我目前正在开发一个Windows Phone 8.1项目,我遇到了ListView的一些困难。我使用C#定义了以下Listview:
ListView addList = new ListView();
//More addList definition.
toAddGrid.Children.Add(addList);
每次用户按下菜单按钮时,我都会向其添加一个包含两个textBox的StackPanel,如下所示:
TextBox fieldEntry = new TextBox();
fieldEntry.PlaceholderText = "Field Name";
//more fieldEntry definiton
TextBox detailsEntry = new TextBox();
detailsEntry.PlaceholderText = "Details";
//More detailsEntry definiton
StackPanel stackPan = new StackPanel();
//More stackPanel definiton
fieldCounter++;
stackPan.Children.Add(detailsEntry);
stackPan.Children.Add(fieldEntry);
addList.Items.Add(stackPan);
基本上,我无法从“addList”中的每个“stackPan”中的textBoxes中检索信息。我希望能够输入字符串并使用它们来创建一个对象。
非常感谢任何帮助。
答案 0 :(得分:-1)
这会有用吗?
foreach (StackPanel panel in addList.Items)
{
foreach (TextBox box in panel.Children)
{
string text = box.Text;
}