This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I use the datagrid with cell templates containing two or more values bound to an entity. I have implemented custom sort comparers and the sort works fine for the column. I always have one primary value to sort on. How can I make the grouping work ? what do I need to do to make the grid group properly on a composite cell. It needs a property to define the field on which to group and also to display in the header line of the group. I use this concept to avoid wide grids, because the fields are not equal in priority. Some of the fields are just secondary and do not justify a separate column or the column might even be very wide.. for example: I build a large tool with over 100 entity types and each entity type has a property Name. Now either one makes the names long and meaningful, which becomes hard to handle eventually, or one can use a "Subtitle" to add meaning to an entity name. This is what I am doing .. So in many places I display a name and subtitle in the same cell (vertical) and the subtitle has the smaller font. Another example is from/to datetime (a time frame) where the from is significant and the to secondary .. same thing : from date on top and to date with smaller font below indented .. there are other situations like this. I do not need grouping everywhere but at some places and it would be not consistent within the application if I have to split up the values from one cell into separate columns .. This also applies for columns where the value is represented by an image using a converter Is grouping supposed to work with custom DataTemplates ?? does not look like it Any idea ? regards gmd EDIT: I figured it out how to do that .. Set PropertyName to the primary field and it will work fine .. I leave this here for reference. one more thing though: Which template do I need to change to show an image in the group header when I use a converter to show images instead of integers regards gmd |
|
|
Hello gmd DataGridColumn has GroupRowHeaderTemplate and GroupRowHeaderTemplateSelector properties which you can use to template the group headers. The data context of the template is the ToString result of the value of the group. Jason Fauchelle |
|
|
ok thanks that worked for the image using a converter How do I bind a Textbox Text to the value of the grouprowheadercontent, {Binding Value} does not work ? It works with a dummy converter, but that is not really elegant isn't it ? regards gmd |
|
|
Hello gmd As the DataContext of the template is the header value, you can just do an empty binding to get the value. i.e. Text="{Binding}" Jason Fauchelle |
|
|
{Binding Mode=OneWay} worked regards gmd |
|