title: How to get a List<string> collection of values from app.config in WPF?
body: <p>The following example fills the <strong>ItemsControl</strong> with a List of <strong>BackupDirectories</strong> which I get from code.</p>
  
  <p><strong>How can I change this so that I get the same information from the app.config file?</strong></p>
  
  <p><strong>XAML:</strong></p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;Window x:Class="TestReadMultipler2343.Window1"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Title="Window1" Height="300" Width="300"&gt;
      &lt;Grid Margin="10"&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="30"/&gt;
              &lt;RowDefinition Height="Auto"/&gt;
          &lt;/Grid.RowDefinitions&gt;
          &lt;Grid.ColumnDefinitions&gt;
              &lt;ColumnDefinition Width="120"/&gt;
              &lt;ColumnDefinition Width="160"/&gt;
          &lt;/Grid.ColumnDefinitions&gt;
          &lt;TextBlock 
              Grid.Row="0"
              Grid.Column="0"
              Text="Title:"/&gt;
          &lt;TextBlock 
              Grid.Row="0"
              Grid.Column="1" 
              Text="{Binding Title}"/&gt;
          &lt;TextBlock 
              Grid.Row="1"
              Grid.Column="0"
              Text="Backup Directories:"/&gt;
          &lt;ItemsControl 
              Grid.Row="1"
              Grid.Column="1"
              ItemsSource="{Binding BackupDirectories}"/&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p><strong>code-behind:</strong></p>
  
  <pre><code>using System.Collections.Generic;
  using System.Windows;
  using System.Configuration;
  using System.ComponentModel;
  
  namespace TestReadMultipler2343
  {
      public partial class Window1 : Window, INotifyPropertyChanged
      {
  
          #region ViewModelProperty: Title
          private string _title;
          public string Title
          {
              get
              {
                  return _title;
              }
  
              set
              {
                  _title = value;
                  OnPropertyChanged("Title");
              }
          }
          #endregion
  
          #region ViewModelProperty: BackupDirectories
          private List&lt;string&gt; _backupDirectories = new List&lt;string&gt;();
          public List&lt;string&gt; BackupDirectories
          {
              get
              {
                  return _backupDirectories;
              }
  
              set
              {
                  _backupDirectories = value;
                  OnPropertyChanged("BackupDirectories");
              }
          }
          #endregion
  
          public Window1()
          {
              InitializeComponent();
              DataContext = this;
  
              Title = ConfigurationManager.AppSettings.Get("title");
  
              GetBackupDirectoriesInternal();
          }
  
          void GetBackupDirectoriesInternal()
          {
              BackupDirectories.Add(@"C:\test1");
              BackupDirectories.Add(@"C:\test2");
              BackupDirectories.Add(@"C:\test3");
              BackupDirectories.Add(@"C:\test4");
          }
  
          void GetBackupDirectoriesFromConfig()
          {
              //BackupDirectories = ConfigurationManager.AppSettings.GetValues("backupDirectories");
          }
  
  
          #region INotifiedProperty Block
          public event PropertyChangedEventHandler PropertyChanged;
  
          protected void OnPropertyChanged(string propertyName)
          {
              PropertyChangedEventHandler handler = PropertyChanged;
  
              if (handler != null)
              {
                  handler(this, new PropertyChangedEventArgs(propertyName));
              }
          }
          #endregion
  
      }
  }
  </code></pre>
  
  <p><strong>app.config:</strong></p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
    &lt;appSettings&gt;
      &lt;add key="title" value="Backup Tool" /&gt;
      &lt;!--&lt;add key="backupDirectories"&gt;
        &lt;add value="C:\test1"/&gt;
        &lt;add value="C:\test2"/&gt;
        &lt;add value="C:\test3"/&gt;
        &lt;add value="C:\test4"/&gt;
      &lt;/add&gt;--&gt;
    &lt;/appSettings&gt;
  &lt;/configuration&gt;
  </code></pre>