title: C#, WPF, bind List<string> to DataGrid
body: <p>I have trouble to bind a List to a DataGrid. It should be as simple as possible. I'm new to WPF and this is for my personal education. </p>
  
  <p>I have a View(Editor),ViewModel(VMText) and a Data(JustText) class.</p>
  
  <p>My source so far:</p>
  
  <p><strong>JustText.cs</strong></p>
  
  <pre><code>namespace Model
  {
      public class Text
      {
          private string _code;
          public string Code
          {
              get { return _code;  }
              set { _code = value; }
          }
  
          public Text()
          {
              _code = "Hello World!\nHow you doin'?";
          }
      } 
  }
  </code></pre>
  
  <p><strong>VMText.cs</strong></p>
  
  <pre><code>namespace ViewModel
  {
      public class VMText
      {    
          private Model.Text _code;
  
          public List&lt;string&gt; Code
          {            
              get { return new List&lt;string&gt;(_code.Code.Split('\n'));        }
              set { _code.Code = System.String.Join("\n", value.ToArray()); }
          }
  
          private View.Editor editor;
  
          public VMText(View.Editor editor)
          {
              _code = new Model.Text();
              this.editor = editor; 
          }
      }
  }
  </code></pre>
  
  <p><strong>Editor.xaml</strong></p>
  
  <pre><code>&lt;Window x:Class="View.Editor"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
          xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
          xmlns:local="clr-namespace:View"
          mc:Ignorable="d"
          Title="Editor" Height="240.024" Width="269.895"&gt;
      &lt;Grid Background="#FF292929" Margin="0,0,-6.8,0.4"&gt;
          &lt;DataGrid x:Name="dataGrid" 
                    HorizontalAlignment="Left" 
                    Margin="0,0,0,0" 
                    VerticalAlignment="Top"
                    Width="200pt"
                    Height="100pt"
                    DataContext="{Binding vmText}"&gt;
              &lt;DataGrid.Columns&gt;
                  &lt;DataGridTextColumn Binding="{Binding Code, UpdateSourceTrigger=PropertyChanged}" Foreground="Black" Width="60" Header="Test" IsReadOnly="false" /&gt;
              &lt;/DataGrid.Columns&gt;
          &lt;/DataGrid&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p><strong>Editor.xaml.cs</strong></p>
  
  <pre><code>namespace View
  {
      public partial class Editor : Window
      {
          private ViewModel.VMText vmText;
  
          #region Constructor
  
          public Editor()
          {
              InitializeComponent();
  
              vmText = new ViewModel.VMText(this);
              DataContext = vmText;
          }
  
          #endregion
      }
  }
  </code></pre>
  
  <p>I just want to show List which is created in VMText in one column in the DataGrid</p>