Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more: , +
I am using WPF toolkit:Datagrid and using EDM as its itemsource.
EDM designer class is giving me an error while I change the first cell in the grid.
It's property is getting binded to the source.
It is giving me an error = "This property cannot be set to a null value."

C#
dgFinancialYear.Columns.Add(new Microsoft.Windows.Controls.DataGridTextColumn { Header = "Financial Year", Binding = new Binding { Path = new PropertyPath("FinancialYear"),  ValidatesOnExceptions = true, ValidatesOnDataErrors = true,  UpdateSourceTrigger = System.Windows.Data.UpdateSourceTrigger.PropertyChanged, NotifyOnSourceUpdated = true, }, Width = 160 });


Above is the code for the grid column and there is no any cell change or cell edit ending event in WPF toolkit:Datagrid


Any help will be highly appreciated.
Posted
Updated 17-Feb-16 23:10pm

1 solution

C#
private void dgFinancialYear_CellEditEnding(object Sender,DataGridCellEditEndingEventArgs e)
{
    if(getCurrentCellValue((TextBox)e.EditingElement)=="")
     {
         e.Cancel=true;
     }
           
}
private string getCurrentCellValue(TextBox txtCurCell)
{
    return txtCurCell.Text;
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900