title: Mode=TwoWay, UpdateSourceTrigger=PropertyChanged or LostFocus?
body: <p>I bind a table of from a Database into a DataGrid using an Observable Collection:</p>
  
  <pre><code>class ViewModel:INotifyPropertyChanged
  {
      private BDDInterneEntities _BDDInterneEntities;
  
      public ViewModel()
      {
          _BDDInterneEntities = new BDDInterneEntities();
          ResultatCollection = new ObservableCollection&lt;Resultat&gt;(_BDDInterneEntities.Resultat);
  
      }         
      public ObservableCollection&lt;Resultat&gt; ResultatCollection { get; set; }
  
      public event PropertyChangedEventHandler PropertyChanged;
  }
  </code></pre>
  
  <p>This is my DataGrid:</p>
  
  <pre><code>&lt;DataGrid x:Name="DonneesBrutes" ItemsSource="{Binding Path=.ResultatCollection, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="10,65,0,0" AutoGenerateColumns="False" EnableRowVirtualization="True" RowDetailsVisibilityMode="VisibleWhenSelected"&gt;
      &lt;DataGrid.Columns&gt;
          &lt;DataGridTextColumn x:Name="PMRQ" Width="*" Binding="{Binding Path=.TOTMPMRQ, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" Header="PMRQ"&gt;&lt;/DataGridTextColumn&gt;
          &lt;DataGridTextColumn x:Name="LibellePMRQ" Width="*" Binding="{Binding Path=.LibelléTOTApres, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" Header="Libellé PMRQ"&gt;&lt;/DataGridTextColumn&gt;
          &lt;DataGridTextColumn x:Name="Ligne" Width="*" Header="Ligne"&gt;&lt;/DataGridTextColumn&gt;
          &lt;DataGridTextColumn x:Name="OTM" Width="*" Header="OTM"&gt;&lt;/DataGridTextColumn&gt;
          &lt;DataGridTextColumn x:Name="TOTM" Width="*" Header="TOTM"&gt;&lt;/DataGridTextColumn&gt;
          &lt;DataGridTextColumn x:Name="LibelleTOTM" Width="*" Header="Libellé OTM"&gt;&lt;/DataGridTextColumn&gt;
          &lt;DataGridTextColumn x:Name="GA" Width="*" Header="GA"&gt;&lt;/DataGridTextColumn&gt;
          &lt;DataGridTextColumn x:Name="Discipline" Width="*" Header="Discipline"&gt;&lt;/DataGridTextColumn&gt;
          &lt;DataGridTextColumn x:Name="DisciplineSubstituee" Width="120" Header="Discipline Substituée"&gt;&lt;/DataGridTextColumn&gt;
          &lt;DataGridTextColumn x:Name="colonnesupp" Width="*" Header="colonne supp"&gt;&lt;/DataGridTextColumn&gt;
      &lt;/DataGrid.Columns&gt;
  &lt;/DataGrid&gt;
  </code></pre>
  
  <p>One Way binding works well, I can see data from my table into my DataGrid.</p>
  
  <p>I have searched about the possibility of being able to send data from my DataGrid to my Database and I found the TwoWay mode and the UpdateSourceTrigger property: <a href="http://msdn.microsoft.com/fr-fr/library/system.windows.data.binding.updatesourcetrigger(v=vs.110).aspx" rel="noreferrer">http://msdn.microsoft.com/fr-fr/library/system.windows.data.binding.updatesourcetrigger(v=vs.110).aspx</a></p>
  
  <p>I think it's a great solution to perform this binding, but I'm not sure about what to do. Is UpdateSourceTrigger best property for me is LostFocus, PropertyChanged?
  Is it enough to do this? My code only works on OneWay, the other way doesn't works.</p>
  
  <p>EDIT1:
  This is the interesting part of app.config File:</p>
  
  <pre><code>&lt;connectionStrings&gt;
      &lt;add name="BDDInterneEntities" connectionString="metadata=res://*/ModelBddInterne.csdl|res://*/ModelBddInterne.ssdl|res://*/ModelBddInterne.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;data source=(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\BDDInterne.mdf;integrated security=true;MultipleActiveResultSets=True;App=EntityFramework&amp;quot;" providerName="System.Data.entityClient" /&gt;
  </code></pre>