title: Populate ListBox
body: <p>I have a window with a textbox and a submit button. When pressing the submit button, the data in the textbox should populate into the listbox and be saved.</p>
  
  <p>What's the best way of doing this? I tried a recommendation (using ObservableCollection) from an earlier question I had, but I can't seem to get it work. I have tried implementing it like this:</p>
  
  <p>I created a class:</p>
  
  <pre><code>public class AccountCollection
  {
      private string accountName;
      public string AccountName
      {
          get { return accountName; }
          set { accountName = value; }
      }
      public AccountCollection(string accountName)
      {
          AccountName = accountName;
      }
  }        
  </code></pre>
  
  <p>Assigned the binding in my XAML:</p>
  
  <pre><code>&lt;ListBox ItemsSource="{Binding AccountName, Mode=TwoWay}" IsSynchronizedWithCurrentItem="True" Height="164" HorizontalAlignment="Left" Margin="12" Name="accountListBox" VerticalAlignment="Top" Width="161" SelectionChanged="accountListBox_SelectionChanged" /&gt;
  </code></pre>
  
  <p>...and finally, when a user clicks the submit button from another window that contains the Submit button and textbox:</p>
  
  <pre><code>private void okBtn_Click(object sender, RoutedEventArgs e)
  {
      BindingExpression expression = okBtn.GetBindingExpression(accountaddTextBox.Text);
      expression.UpdateSource();
  }
  </code></pre>
  
  <p>But alas, I'm getting nowhere. I get an error message at the GetBindingExpression section:</p>
  
  <p>Argument 1: cannot convert from 'string' to 'System.Windows.DependencyProperty'</p>
  
  <p>What's obvious to me here is that when I created the class I didn't specify anything about the account name from the textbox, so I don't even know if the class is correct.</p>
  
  <p>I'm basically confused and don't know what to do. Any help would be appreciated...</p>