Hi,I am using XamDataGrid in my application and using SummaryDefinition to show summary information like Sum, Average etc as part of that. Background color and brush color of Summary Record spans over the entire width of grid but I want to limit that only till data area. I have attached the screenshot for better understanding. As highlighted in the screenshot, I want to show background color only till end of Column "Q1_Col_4".Please provide me a sample to refer.
Thanks,Mahadev
Hello Mahaved,
Thank you for your post. I have been looking into your requirement and in order to achieve the desired functionality you could use a keyless Style that would apply to all SummaryResultPresenters with DataTriggers. Since you do not have direct access to the name of the Field, which would trigger any difference in the presenter’s appearance I have created a IValueConverter to get to the Field’s name. Here are both the sample xaml style and the converter code I have used to get red summaries for the “name” Field and blue for the “sales” Field:
<Style TargetType="{x:Type igDP:SummaryResultPresenter}">
<Style.Triggers>
<DataTrigger Binding="{Binding Converter={StaticResource MyFieldNameCon}}" Value="Capacity">
<Setter Property="Background" Value="Yellow" />
<Setter Property="Foreground" Value="Green" />
</DataTrigger>
<DataTrigger Binding="{Binding Converter={StaticResource MyFieldNameCon}}" Value="Mileage">
<Setter Property="Background" Value="LightCoral" />
<Setter Property="Foreground" Value="SeaGreen" />
</Style.Triggers>
</Style>
…
public class MyConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
return (value as SummaryResultEntry).SummaryResult.SourceField.Label.ToString();
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
return value;
I am attaching a sample application(DataGridSummaryDefinitions.zip) that shows this approach.
Let me know, if you need any further assistance on this matter.
Hi Yanko,
This won't serve my problem. I wanted to show some background color (say Green) till data and make the rest as white. By that way, I will be able to highlight summary record only till data exists. Note: Summary may not be applied to all the columns.
Please let me know is there a way to achieve this.