Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You need to bind to a list of type ObservableCollection then every update to the list collection will trigger the binding to update.</p> <p>Example on how to create an observable collection of your list:</p> <pre><code>public ObservableCollection&lt;string&gt; MyElements { get; set; } public void FillList() { List&lt;string&gt; testList = new List&lt;string&gt;() {"string1", "string2"}; MyElements = new ObservableCollection&lt;string&gt;(testList); } </code></pre> <p><code>MyElements.Add("string3")</code> will trigger binding to update</p> <p>EDIT: I added a working example, I provide the xaml and ViewModelCode with the use of acommand to add some strings:</p> <p>xaml:</p> <pre><code>&lt;ListBox ItemsSource="{Binding MyStrings}" /&gt; &lt;Button Command="{Binding AddExtraStringCommand}" Content="Add ExtraString" /&gt; </code></pre> <p>viewmodel.cs</p> <pre><code>public class Window1ViewModel : ViewModelBase { public ObservableCollection&lt;string&gt; MyStrings { get; set; } public RelayCommand AddExtraStringCommand { get; set; } public Window1ViewModel() { patient = new Patient() { BirthdayString = "21/11" }; MyStrings = new ObservableCollection&lt;string&gt;() { "string1", "string2", "string3" }; AddExtraStringCommand = new RelayCommand(AddExtraString); } public void AddExtraString() { MyStrings.Add("nog enen extra om: " + DateTime.Now); } } </code></pre> <p>I don't have to trigger the RaisePropertyChanged to make it work. Maybe you can check your code to this code example.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload