Hi,
I've got a XamDataGrid with two Summary Columns (two SummaryDefinitions) and tried to create a SummaryResultPresenter for each of them. Both of them get a key so they aren't assigend to every SummaryResultResult per default.
The problem is that I can't figure out where to use this keys? I can't set it on the SummaryDefinition and applying it on the editor on the fields won't work either.
Definition of the Styles:
<igDP:XamDataGrid.Resources> <Style TargetType="{x:Type igDP:SummaryResultPresenter}" x:Key="PercentSummaryStyle"> <Setter Property="Control.Background" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=SummaryResult.Value, Converter={StaticResource colorConverter1}}"/> </Style> <Style TargetType="{x:Type igDP:SummaryResultPresenter}" x:Key="CountSummaryStyle"> <Setter Property="Control.Background" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=SummaryResult.Value, Converter={StaticResource colorConverter2}}"/> </Style></igDP:XamDataGrid.Resources>
Definition of the Summary:
<igDP:FieldLayout.SummaryDefinitions> <igDP:SummaryDefinition Key="idp_percent" SourceFieldName="Percent" Calculator="Sum" /> <igDP:SummaryDefinition Key="idp_count" SourceFieldName="Count" Calculator="Sum" /></igDP:FieldLayout.SummaryDefinitions>
Thanks in advance,Thomas
Hi Thomas,
Currently there is no way to set different SummaryResultPresenter styles for each of the fields - so you would need to use only one style. In order to obtain the name of the field associated with the summary result you can use the SummaryResult.SourceField property. Attached is a simple sample so you can see my implementation.
<Grid.Resources> <local:MultiColorConverter x:Key="multiColorConverter"/></Grid.Resources>
<Style TargetType="{x:Type igDP:SummaryResultPresenter}"> <Setter Property="Background"> <Setter.Value> <MultiBinding Converter="{StaticResource multiColorConverter}"> <Binding Path="SummaryResult" RelativeSource="{RelativeSource Self}"/> <Binding Path="SummaryResult.Value" RelativeSource="{RelativeSource Self}"/> </MultiBinding> </Setter.Value> </Setter></Style>
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { SummaryResult result = values[0] as SummaryResult; string resultName = (result.SourceField as Field).Name;
int resultValue = 0; bool b = int.TryParse(values[1].ToString(), out resultValue);
if (resultName == "MyProperty1") { // return brush object based on the resultValue } else if (resultName == "MyProperty2") { // return brush object based on the resultValue } return Binding.DoNothing;}
Let me know if this would work in your scenario and if you have any questions.
Thank you, works fine!
The attached Sample cannot be downloaded. Could this be attached pls.
Thanks
Raul
Hello Raul,
I have created a sample project for you folllowing Vlad approach.
Hope it helps you.