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
No Data
Reply
  • 29105
    Offline posted

    Hello Mateusz,

    Thank you for contacting Infragistics. Please clarify what issues you are seeing and provide an isolated sample demonstrating the behavior. Are you dragging merged cells within the same grid? Keep in mind drag drop support is not a built in feature of the grid and there will be limitations applying borders to rows and merged cells that are going to be dragged. This is considered to be a new product idea.

    You can suggest new product ideas for future versions (or vote for existing ones) at <https://es.infragistics.com/community/ideas>.
    Submitting your idea will allow you to communicate directly with our product management team, track the progress of your idea at any time, see how many votes it got, read comments from other developers in the community, and see if someone from the product team has additional questions for you.
    Remember when submitting your idea to explain the context in which a feature would be used and why it is needed as well as anything that would prevent you from accomplishing this today. You can even add screenshots to build a stronger case. Remember that for your suggestion to be successful, you need other members of the community to vote for it.   You can also link back to this thread for additional details.

    Let me know if you have any questions.

    Michael DiFilippo
    Software Developer
    Infragistics, Inc.

Children