Hi,
I want to style cells differently if they are in the last row of the grid.
I partially achieved it using converter using the following code:
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
DataRecord record = value as DataRecord;
if (record == null)
return false;
return record.VisibleIndex == record.ParentCollection.Count - 1;
}
But after sorting the grid it does not work.
Id there any way to determine that DataRecord is in the last row?
Thanks.
Hello Dierk,
Thank you for your post. I have been looking into you requirement and I created a sample project for you with the functionality you want. Basically I created a Style for the DataRecordCellArea and with a Converter a determine the last record and set its Background. Also I set the XamDataGrid’s RecordContainerGenerationMode to Virtualize, so that the DataTrigger could works correctly. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
Thanks,
Seems to be working fine with RecordContainerGenerationMode="Virtualize"
Is there any way to achieve same result with RecordContainerGenerationMode="Recycle"?
We find recycle mode performing better than virtualize and using Recycle in our app.
it works with initial load, but if I click on column header and sort the grid, the last row could be different row and style is not applied.
Thanks again
I am just checking if you got this worked out or you still require any assistance or clarification on the matter.
Hello,
I have modified the sample project I sent you before, so now the RecordContainerGEnerationMode is set to Recycle. This time I handled the Sorted event and change the LastRecord Background. Also in the Sorting event I change the last Record background to white first, because after sorting it may not be last record anymore.
Hope this helps you.