title: How do I fix "Two-way binding requires Path or XPath" exception in WPF Datagrids?
body: <p><strong>Background/context for this question:</strong>
  I have a WPF desktop application. It uses LINQ to SQL to connect to its SQL database, and it displays its data in WPF Datagrids. It was working fairly well, but performance was a problem because LINQ can be deadly slow, so I have been switching my logic and UI controls away from LINQ database contexts as much as possible, and instead loading them into local variables which are very similar to the LINQ objects, which massively improves performance.</p>
  
  <p><strong>The problem:</strong>
  As I test my Datagrids, I am now getting a new exception "<strong><em>Two-way binding requires Path or XPath.</em></strong>" when I try to edit the value in a certain (integer) column of one Datagrid, though editing string columns had been working fine. I don't understand why I am getting this, or what to do about it.</p>
  
  <p>So it worked when the datagrid.datacontext was set to a LINQ entity association, but it only almost works when it is set to a list of plain objects. I tried changing the list to an ObservableCollection, but this had no apparent effect.</p>
  
  <p>I have looked at about a dozen different related questions here and on other sites, and am not seeing anything that seems to help.</p>
  
  <p>Currently I have:</p>
  
  <pre><code>&lt;DataGrid Margin="12,110,12,0" x:Name="dgDays" ItemsSource="{Binding}" 
                   Height="165" VerticalAlignment="Top" MinHeight="0" 
                   AutoGenerateColumns="False"
                   SelectionChanged="dgDays_SelectionChanged"&gt;
  </code></pre>
  
  <p>...</p>
  
  <pre><code>&lt;DataGrid.Columns&gt;
              &lt;DataGridComboBoxColumn Width="80" Header="Cook" x:Name="_DailyCookCombo" SelectedItemBinding="{Binding sCook}"/&gt;
              &lt;DataGridComboBoxColumn Width="80" Header="Eat" x:Name="_DailyDayCombo" SelectedItemBinding="{Binding sDay}"/&gt;
              &lt;DataGridTextColumn Width="52" Header="Prot" Binding="{Binding Protein}" /&gt;
              &lt;DataGridTextColumn Width="52" Header="Carb" Binding="{Binding Carb}" /&gt;
              &lt;DataGridTextColumn Width="52" Header="Fat" Binding="{Binding Fat}" /&gt;
              &lt;DataGridTextColumn Width="62" Header="Prot %" Binding="{Binding ProteinPercent}" /&gt;
              &lt;DataGridTextColumn Width="62" Header="Carb %" Binding="{Binding CarbPercent}" /&gt;
              &lt;DataGridTextColumn Width="62" Header="Fat %" Binding="{Binding FatPercent}" /&gt;
              &lt;DataGridTextColumn Width="116" Header="non PFW meals" Binding="{Binding NonPFWMeals}" /&gt;
              &lt;DataGridTextColumn Width="55" Header="Prot" Binding="{Binding CalcProt}" IsReadOnly="True" /&gt;
              &lt;DataGridTextColumn Width="55" Header="Carb" Binding="{Binding CalcCarbs}" IsReadOnly="True" /&gt;
              &lt;DataGridTextColumn Width="55" Header="Fat" Binding="{Binding CalcFat}" IsReadOnly="True" /&gt;
              &lt;DataGridTextColumn Width="65" Header="KCal" Binding="{Binding CalcKCal}" IsReadOnly="True" /&gt;
              &lt;DataGridCheckBoxColumn Width="32" Header="Skip" Binding="{Binding Skip}"  /&gt;
              &lt;DataGridTextColumn Width="70" Header="Date" Binding="{Binding sNextDate}" IsReadOnly="True" /&gt;
          &lt;/DataGrid.Columns&gt;
      &lt;/DataGrid&gt;
  </code></pre>
  
  <p>which is bound by the code:</p>
  
  <pre><code>dgDays.DataContext = TheMember.RAM_Member_Requirements_Days;
  </code></pre>
  
  <p>which is defined as:</p>
  
  <pre><code>public ObservableCollection&lt;RAM_Member_Requirements_Day&gt; RAM_Member_Requirements_Days = new ObservableCollection&lt;RAM_Member_Requirements_Day&gt;();
  </code></pre>
  
  <p>whose bound members are:</p>
  
  <pre><code>    public class RAM_Member_Requirements_Day : INotifyPropertyChanged
  {
      // RAM equivalents of DB values:
  public System.Nullable&lt;decimal&gt; Protein;
  public System.Nullable&lt;decimal&gt; Carb;
  public System.Nullable&lt;decimal&gt; Fat;
  public System.Nullable&lt;decimal&gt; ProteinPercent;
  public System.Nullable&lt;decimal&gt; CarbPercent;
  public System.Nullable&lt;decimal&gt; FatPercent;
  public System.Nullable&lt;int&gt; NonPFWMeals;
  public System.Nullable&lt;bool&gt; Skip;
  public System.Nullable&lt;System.DateTime&gt; SkipDate;
  </code></pre>
  
  <p>I found a very simple fix shortly after typing this, which I'll post when the site lets me after its 8-hour delay.</p>