I have a simple DataGrid which I am binding to a ObservableCollection and its producing black small lines in the Grid with no Data Visible. I am using ObservableCollection as I have the collection being built in RunTime using Reflection.
I am doing something like this
XAML
<DataGrid ItemsSource="{Binding Data}" />
C#
public ObservableCollection<object> Data
{
get { return _Data; }
set {
this._deals = value;
this.NotifyPropertyChanged("Deals");
}
}
public Run()
{
this.Data = CreateData(typeof(MyRecordClass)) //'MyRecordClass' needs to be passed at runtime
}
public ObservableCollection<Object> CreateData(Type RecordType)
{
ObservableCollection<Object> data = new ObservableCollection<object>();
var record = Activator.CreateInstance(RecordType);
// Logic to load the record with Data
data.Add(record);
return data;
}
Is there a way in which I can make the DataGrid read an ObservableCollection without specifying the ColumnNames or create a ObservableCollection object in the CreateData function ?