Hello,
This is a class I use to display on grid:
public class Person :INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String info)
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
private string _company;
private DateTime? _date;
public int ID { get; set; }
public string Company
get { return _company; }
set {
if (string.IsNullOrEmpty(value))
throw new Exception("Company must not be empty");
_company = value;
NotifyPropertyChanged("Company");
public DateTime? Date
get { return _date; }
set
_date = value;
NotifyPropertyChanged("Date");
public string Name { get; set; }
public KeyValue Field { get; set; }
public Person(int id, string name, string comp, DateTime date, KeyValue field)
ID = id;
Name = name;
Company = comp;
Date = date;
Field = field;
public Person()
And this is a part of XAML which displays Date property:
<igGrid:TemplateColumn Key="Date">
<igGrid:TemplateColumn.HeaderTemplate>
<DataTemplate>
<TextBlock Text="Date" />
</DataTemplate>
</igGrid:TemplateColumn.HeaderTemplate>
<igGrid:TemplateColumn.ItemTemplate>
<TextBlock Text="{Binding Date}"/>
</igGrid:TemplateColumn.ItemTemplate>
<igGrid:TemplateColumn.EditorTemplate>
<controls:DatePicker Text="{Binding Date, Mode=TwoWay}" />
</igGrid:TemplateColumn.EditorTemplate>
</igGrid:TemplateColumn>
Each time I enter edit mode and clear date value, and then move cursor to next row or cell, Date cell won't become empty and empty date won't save to datasource. What is the problem?
BTW the same thing happens when I'm using DateColumn.
Thank you.
Using the Date Column I was not able to reproduce your results,
<iggrid:XamWebGrid x:Name="grid">
</iggrid:XamWebGrid>
public class Person : INotifyPropertyChanged
private DateTime? _dob;
public int Age { get; set; }
public DateTime? DOB
get
return this._dob;
if (this._dob != value)
this._dob = value;
#region INotifyPropertyChanged Members
#endregion
public MainPage()
InitializeComponent();
this.grid.EditingSettings.AllowEditing = EditingType.Cell;
ObservableCollection<Person> p = new ObservableCollection<Person>();
p.Add(new Person() { Name = "bob", Age = 2, DOB= DateTime.Now });
this.grid.ItemsSource = p;
Using the TemplateColumn I was able to reproduce you behavior, but that is because of a quirk in the DatePicker control. The DatePicker doesn't finalize until after the blur on the control is called by the framework when entering text. By this time the binding has already been called to update.
This was one of the reasons why we created a Date Column.
Since I am able to null out the text of a DateColumn, could you provide either a sample or explicit steps to reproduce your issue?
Thank you for reply.
Regarding DatePicker control, I tried to do something with it and already started to think somebody has eaten my brain. Thank you for pointing me to such control behavior. Do you know any DatePicker control which behaves correctly within your grid?
Yes it works ok when I'm using DateColumn. That was because of my code.