Reputation: 31
I have a question for you. In XAML i created listview with name listviewtest and textbox with name txtUser. My problem is when i add this textbox txtUser to listviewtest, it will be there, but if i change text in textbox txtUser second time, listviewtest add changed textbox txtUser. What i need to do is add textbox txtUser to listviewtest and if it will be changed there will be two textboxs - first verion and changed version.
My code right now is very simple:
List<string> namesofusers = new List<string>() { };
string nameofuser = txtUser.Text;
namesofusers.Add(naazov);
listviewtest.ItemsSource = namesofusers;
Upvotes: 1
Views: 76
Reputation: 45106
This will create a new List so the old list will go away.
List<string> namesofusers = new List<string>() { };
Declare List<string> namesofusers;
elsewhere
Bind once - preferable in XAML to a public property
You many need to use an ObservableCollection rather than List
if (namesofusers == null)
namesofusers = new List<string>();
Upvotes: 0