I'm using the XamDataGrid in a large project and I'm now trying to style it.
I haven't been able to find any useful information on this subject though.
I'm using hierarchical data and I would therefor like to know how to style the different rows. Especially I would like "child"-rows to have a different backgroundcolor than the "parent".
Is there some kind of reference list with types/properties that I can use?
Thankyou for your suggestion.
I also found a way to make this work using an AssigningFieldLayoutToItem event.
In the XamDataGrid, assign the event as such : AssigningFieldLayoutToItem="QueryBlock_AssigningFieldLayoutToItem"
then handle the event like this
private void QueryBlock_AssigningFieldLayoutToItem(object sender, Infragistics.Windows.DataPresenter.Events.AssigningFieldLayoutToItemEventArgs e) { FieldLayout resultLayout = new FieldLayout(); if (e.ParentExpandableFieldRecord == null) resultLayout = QueryBlock.FieldLayouts["Parent"]; else resultLayout = QueryBlock.FieldLayouts["Child"]; e.FieldLayout = resultLayout; }
This way your first tier of information is styled as whatever is defined in a "Parent" style, and all other levels as "Child"
I Hope this is of help to somebody.
Hello,
It has been a while since you have made your post, in case you still need support I will be glad to assist you further. I suppose the other community members can benefit from this answer as well. I have been looking into your post and I modified the sample I attached in some of my previous posts, so now it works with recursive data. Basically I handled the DataRecordPresenter’s Loaded event and check on which level it is and set different Background.
Feel free to write me if you have further questions.
Sorry to resurrect this post, but I am trying to do the same thing, but with a recursive hierachy..
Basically modifying the example you gave, but instead of having a Person object with a collection of Strings as Children, Being able to have a Person contain a Collection of Person.... I tried this but the child rows just inherit the same styling as the parent.
Any suggestions on fixing this?
thanks
Thank you for your post. I have been looking through it and I created a sample project for you. Basically I create two styles for the different FieldLayouts and set different colors. Please let me know if you need further assistance on this matter.
Looking forward for your reply.