//Just to simulate database in a constructor. public EspLabTestViewModel() { MyDisplayListBox.Add(new KeyValuePairModel { Key = "Hello", Value = "World" }); MyDisplayListBox.Add(new KeyValuePairModel { Key = "FirstName", Value = "Sujit" }); MyDisplayListBox.Add(new KeyValuePairModel { Key = "Language", Value = "CSharp" }); MyDisplayListBox.Add(new KeyValuePairModel { Key = "MVVM", Value = "Caliburn" }); }
public void AddToList(string inputTextBox) { ValidateInput(inputTextBox); if (Key != null || Value != null) { KeyValuePairModel newKeyValuePair = new KeyValuePairModel { Key = Key, Value = Value }; MyDisplayListBox.Add(newKeyValuePair); NotifyOfPropertyChange(() => MyDisplayListBox); } }