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
50
Merged cell style depending on first merged row
posted

Hello,

I have implemented a cell merging in my XamDataGrid. I overrode the default Infragistics template to provide functionality that adds custom border if there is a property "DropTargetType" in the underlying row equal to custom enum "DropTargetType.Regular".

BUT, there is strange behavior I don't know how to deal with: the merged cell style's DataContext is set to the last of merged rows. How can I change this DataContext to the first merged row?

There is a simple code I use. It works correctly if the property in the last of merged rows "DropTargetType" is equal to "DropTargetType.Regular". However, I would like it to be dependent on the first merged row.

    <Style TargetType="{x:Type igDP:MergedCellPresenter}" x:Key="DefaultMergedCellPresenter">
        <Setter Property="Background" Value="{DynamicResource {x:Static igDP:DataPresenterBrushKeys.MergedCellBackgroundKey}}"/>
        <Setter Property="BorderBrush" Value="{StaticResource CellItemNormalBorderBrush}"/>
        <Setter Property="BorderThickness" Value="0 0 1 1"/> <!--Econosim change-->
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type igDP:MergedCellPresenter}">
                    <!--change start-->
                    <Border
                        x:Name="DropTargetBorder"
                        BorderThickness="0 0 0 0"
                        BorderBrush="Black">
                    <!--change end-->
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            >
                        <igDP:CellValuePresenter x:Name="PART_CellValuePresenter"
                            Field="{TemplateBinding Field}"
                            Value="{TemplateBinding Value}"                     
                            BorderThickness="0"
                            IsMergedCell="True"/>
                    </Border>
                    </Border>
                    <ControlTemplate.Triggers>
                        <!--change start-->
                        <DataTrigger Binding="{Binding DataItem.DropTargetType}" Value="{x:Static utils:DropTargetType.Regular}">
                            <Setter Property="BorderThickness" Value="0 1 0 0" TargetName="DropTargetBorder"/>
                        </DataTrigger>
                        <!--change end-->

                        <Trigger Property="IsOpacityReduced" Value="True">
                            <Setter TargetName="PART_CellValuePresenter" Property="Opacity" Value="0.35"/>
                        </Trigger>
                        <Trigger Property="IsFieldSelected" Value="True">
                            <Setter Property="Background" Value="{DynamicResource {x:Static igDP:DataPresenterBrushKeys.MergedCellFieldSelectedBackgroundKey}}"/>
                            <Setter Property="BorderBrush" Value="{DynamicResource {x:Static igDP:DataPresenterBrushKeys.MergedCellFieldSelectedBorderBrushKey}}"/>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsFixed" Value="True"/>
                                <Condition Property="IsRecordSelected" Value="False"/>
                                <Condition Property="IsSelected" Value="False"/>
                                <Condition Property="IsFieldSelected" Value="False"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Background" Value="{DynamicResource {x:Static igDP:DataPresenterBrushKeys.MergedCellFieldFixedBackgroundKey}}"/>
                            <Setter Property="BorderBrush" Value="{StaticResource CellItemNormalBorderBrush}"/>
                        </MultiTrigger>
                        <Trigger Property="IsRecordSelected" Value="True">
                            <Setter Property="Background" Value="{DynamicResource {x:Static igDP:DataPresenterBrushKeys.MergedCellRecordSelectedBackgroundKey}}"/>
                            <Setter Property="BorderBrush" Value="{StaticResource CellItemNormalBorderBrush}"/>
                        </Trigger>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Background" Value="{DynamicResource {x:Static igDP:DataPresenterBrushKeys.MergedCellSelectedBackgroundKey}}"/>
                            <Setter Property="BorderBrush" Value="{StaticResource CellItemNormalBorderBrush}"/>
                        </Trigger>

                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

Best regards,

Mateusz

Parents Reply Children