I am creating a fieldlayout dynamically by handling the FieldLayoutInitialized event and adding unbound fields to the fieldlayout present in the event args. When this is done, it seems that although this event handler is called and fields are added, the field headers don't show up in the UI when there are no elements in the collection that represents the DataSource. I can tell that fields are getting set because summary rows are present for each field I have created. When the collection is populated with at least one object, field headers are rendered.
FYI I am depending on the XamDataGrid to invoke the FieldLayoutInitialized event when I do the following:
grid.ResetFieldLayouts();
grid.DataSource = null;
grid.SetBinding(XamDataGrid.DataSourceProperty, "DataSourceBindingPathHere"
I have noted that column headers do seem to be displayed when I define the fieldlayouts completely in XAML - even when there are no elements in the underlying DataSource collection. What am I missing to get Field Headers to display when dynamically creating columns?
Hello,
I am not completely sure if this is supposed to work, when you set the DataSource to null, but the headers should appear if you set the data source to an empty list, like this:
grid.DataSource = new List<MyClass>();
Another problem.
If there are multiple layouts and DataSource is an empty list, XamDataGrid always displays the first layout. It ignores IsDefault and DefaultLayout properties.
How to make it to display the correct layout???