Hi Jenny,
Thanks for the assistance with this. And yes, I agree, this seems a much better way to set the DataCell values rather than programmatically setting their local values for the reasons you said.
However, the reason I wanted to do it programmatically is because I want to set the colours of cells based on values of cells in other rows. In particular, I want to set the Background of a cell to a different colour if the equivalent cell (same field) in the previous row is different. In fact, I want to do this by grouping as well!
In the example attached (a modified version of the example I attached to a previous post), the DataRow_SizeChanged event handler (registered in the Page constructor) programmatically changes the Background of each cell if the same-column cell in the previous row (Index minus one) has a different value. Could the same effect be achieved in XAML using Style Triggers and Setters?
And if I do end up having to do this programmatically rather than through XAML, there must be a better way of getting at the DataRow than having to catch the SizeChanged event? And remember, I need to do this by Group as well, which will be set up programmatically through the DataGridControl.Items.GroupDescriptions property beforehand.
If all else, fails, I can always change the structure of the source data (a DataTable) to include an extra field with the value in each row for this field containing an array of fields (or field names) for that row that contain different values to the equivalent fields in the previous row. If I did it that way, would I be able to use the Condition Binding that you suggested in XAML to see if the field (name) is contained within field containing the array of field (names) using a converter or something? E.g.:
<Condition Binding="{Binding Path=ChangedFields, Converter={StaticResource fieldNamesConverter}}" Value="True" />
I look forward to any help you can give.
Many thanks,
Jason
Associate, .NET Development
Morgan Stanley, UK