I just stumbled upon a behavior of the DataGrid
in WPF and frankly I don't know if I did something wrong or its the standard behavior of the WPF DataGrid
.
So I have an interface, let's call it IItem. IItem has couple of properties (Name, Active, Timestamp). This interface inherits from an other interface lets call it IBaseItem. IBaseItem also has properties (Id, Selected, Active, Timestamp). So I would expect when I create a DataGrid
in XAML with AutoGenerateColumns=true
and the binding source is a List<IItem>
then It would generate the Id and the Selected columns as well.
Instead it only generates the Name, Active and Timestamp properties as columns. And the Name is not editable (although it has a setter property) but Active is.
public interface IBaseItem : INotifyPropertyChanged
{
bool Selected { get; set; }
int Id { get; }
bool Active { get; set; }
DateTime Timestamp { get; set;}
}
public interface IItem: IBaseItem, IEditableObject
{
string Name { get; set; }
new bool Active { get; set; }
new DateTime Timestamp { get; }
}
But if I break the inheritance chain and make the IItem as an individual interface then voila the Name become editable.
I don't get why the inheritance is messing things up. Can anyone enlighten me?