Hello,
I think I have a very simple question but I can't find a solution for this.
How can I still show the header (FieldLayouts & a filled in Group By Area) of the XamDataGrid even when XamDataGrid is bound to an empty list?
XamDataGrid only shows the "Group by" area but also with no items in there.
So I want to show the header and a filled in "Group By" header even when there are no items in the list?
Thanks,Bert Janssens
I realize this is quite old now but I actually just ran into this problem myself. We happen to use column configurations that are read in from the database that make all of our grids and settings dynamic. Because of this, we are able to add the fields to the grid even if there are no records via the "AssigningFieldLayoutToItem" method. This method gets hit even if there are no records, so it serves for what we are trying to accomplish.
Just to add info for topics maybe it helps someone.
So...
I have a next issue:
1. Base class Class1 with fields X, Y
2. Extended class Class2 : Class1 with additional field Z
3. ObservableCollection<Class1>
4. XamDataGrid with FieldLayouts for X,Y,Z.
What have I seen:
When no data in collection there is no header in grid.
After adding some values of type Class2, data existed also with a proper header.
What helps me with no data in collection:
change collection to ObservableCollection<Class2>
Hi,
Is there any valid solution to this problem?
Thanks,
VJ
Thank you for posting your solution. I'm having some difficulty, however, implementing it. I'm not 100% sure I have interpreted this correctly, but I have achieved something resembling the result you described. The result, however, has some unfortunate ramifications, which I'll explain in a few paragraphs. For clarification, my implementation included the following aspects:
With this implementation, I now seem to get a result where the column headers do not go away with an empty collection, but I get a grid which has a few unfortunate features:
My primary meaning is not to nit-pick your workaround but rather to ask whether this was indeed the result you obtained. I tried several other permutations interpreting your solution including the following:
Any insights would be appreciated.
There is a bug in the xamdatagrid where if you only have collections and all the collections are empty it wont show the collection headers. However, if even one collection is not empty it will show all the headers if the ExpandableFieldRecordHeaderDisplayMode is set to AlwaysDisplayHeader. So to override the bug add a dummy collection to your data object which has a non empty collection and set the browsable attribute to false so it wont show up in the xamdatagrid. I use the following
private readonly BindingList<string> DummyForXamDataGridBackingField ;
public dataobject(){ string dummycollectionitem = "This is here to force the xamdatagrid to show the headers in the other browsable collections"; DummyForXamDataGridBackingField = new ThreadedBindingList<string> { dummycollectionitem };
}
[Browsable(false)]public ThreadedBindingList<string> DummyForXamDataGrid{ get { return DummyForXamDataGridBackingField; }}
works like a charm.