Hello,
I am using WPF NetAdvantage 2012.2 (and cannot update to a later version).
I am grouping my data by two values. For example, first group by "Name" then by "Department".
I need the top level group by row to have a different style then the child group by row.
If I wanted the top level group row height to be taller than the child group row, how would I do that? Or have it use a different background color?
Can someone provide me a sample showing how to do that? I suspect we would need to create some StyleSelector but I do not know how to apply the selector to the GroupByRows.
Or maybe it can be done using a single style with some converters.
Thanks for the help.
Hello Torque,
Thank you for your post.
I believe your best option here would be to write a StyleSelector for use with the XamDataGrid.FieldSettings.GroupByRecordPresenterStyleSelector property. Before writing this style selector, I would recommend that you merge the default GroupByRecordPresenter style into your project. This style can be found in the DataPresenterGeneric_Express.xaml file, commonly found at C:\Program Files (x86)\Infragistics\<your version here>\WPF\DefaultStyles\DataPresenter. Once you have included this default style in your project and its dependencies, I would recommend locating a Border object named "Highlight" and modify the Background property of it to bind to the TemplatedParent's Background property ({Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}). This will allow the Background property of a separate style based on this default style to take effect.
Once you have done this, you can override the SelectStyle method of your StyleSelector and create a Style of type GroupByRecordPresenter based on the default style included as mentioned above. The item property of this StyleSelector.SelectStyle method will be the GroupByRecord which the GroupByRecordPresenter represents, and I would recommend casting it to a GroupByRecord. From here, you can check if the grouped field is the first grouped one by using the static GroupByAreaMulti.GetIsFirstInList method. This method takes a field as a parameter, which would be the field that you have grouped by. You can get this field from the GroupByRecord's GroupByField property. If it is the first one, you can apply your style accordingly.
If not, then I would recommend that you go to the XamDataGrid, which you can retrieve from the GroupByRecord's DataPresenter property. From here, I would recommend that you query the XamDataGrid's DefaultFieldLayout.SortedFields collection for the items that have their IsGroupBy properties set to true, and get a list of these items. These items will be of the type FieldSortDescription, and they will appear in that collection in the order that you have grouped your fields. You could also just check if the count of this collection is 2 and the GetIsFirstInList method mentioned above returns false, but that would limit you to only being able to style up to 2 levels of grouping. One of the resultant "IsGroupBy = true" FieldSortDescription objects will have a Field that corresponds directly to your GroupByRecord.GroupByField. I would recommend that you find this one, and then you can get its index from the list mentioned above to find out which level of grouping this is. Then, you can style the GroupByRecordPresenters accordingly by setting the Background property, or the Height property for your requirements.
I have attached a sample project to demonstrate the above. I hope this helps you.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support