I have a DataTable which containes some data from a sql database. I want to bind this dataTable to a dataGrid using mvvmcross. Here are my codes :
In ModelView :
private DataTable _groupeData;
public DataTable GroupeData
{
get { return _groupeData; }
set
{
_groupeData = value;
RaisePropertyChanged(() => GroupeData);
Runned++; //In order to check if the dataTable has updated
UpdateElementGroupe(EltId, value); //A method that will update the database using the values in this dataTable
}
}
In View :
<DataGrid ItemsSource="{Binding Path=GroupeData}" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Header="Name" Binding="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<DataGridTextColumn Header="Description" Binding="{Binding Description, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
</DataGrid.Columns>
</DataGrid>
With these codes, I'm able to show dataTable's data in DataGrid, but when I modify a cell in dataGrid, the dataTable doesn't update (as if I had set Mode = OneWay).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…