Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
95
Multiple SummaryDefinitions with different Converters
posted

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

Parents
No Data
Reply
  • 9836
    posted

    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.

Children