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
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 DiFilippoSoftware DeveloperInfragistics, Inc.
I do not use any drag and drop functionality. This is just the name of an enum.
I've created very simplified example which shows how currently cell merging works. In the attached jpeg file I show how it should work.
The issue is that the style of the merged cell is taken from the second of merged rows (see row "Santana Kate" in the first image) instead of expected by me first row (see "Smith John" in the second image). Because of this the table seems ugly.
XamDataGridMergedRowStyleDemo.7z
I would appreciate your help.
Best regards.
Thank you but I do not see anything uploaded for me to get.
Maybe this link: https://easyupload.io/60lyzt
easyupload.io/60lyzt
Best regards
Thank you for following up. I reviewed your sample and noticed it's only using a CellValuePresenter style. You are going to need a combination of both a CellValuePresenter style and MergedCellPresenter style (see attached). However merged cells still have cellvaluepresenters next to them which makes it difficult to achieve this requirement for when clicking the cells. I would try and keep it simple. Styling merged cells is alone is easily achievable but doing so with the row in mind is considered to be a new product idea.XamDataGridMergedRowStyleDemo.zip
I have checked your attached project and, to be honest, I don't see any difference in behavior to the previous state without merged cell style. I mean, the style of a merged cell still depends on the second of the merged rows instead of the first one. I have simplified a little bit your last project to focus only on merged cell - I removed border over normal cells.
If you confirm that there is nothing I can do to make the red border to be only above "Smith" instead of "Santana" then I will give up on this idea in my program.
Project: https://easyupload.io/8193e3
Thank you, this solution helped me. I also added trigger to CellValuePresenter so that it doesn't show line if it is merged cell - responsible for this is a piece of code from you added to MergedCellPresenter. This resolved my problem.
<MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding DataItem.ShowLine}" Value="True"/> <Condition Binding="{Binding IsMergedCell, RelativeSource={RelativeSource Self}}" Value="False"/> </MultiDataTrigger.Conditions> <Setter Property="BorderThickness" Value="0 1 0 0" TargetName="DropTargetBorder"/> </MultiDataTrigger>
Try updating your trigger in your mergedcellpresenter.
eg.
<ControlTemplate.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=DataRecords[0].DataItem.ShowLine}" Value="True"> <Setter Property="BorderThickness" Value="0 1 0 0" TargetName="DropTargetBorder"/> </DataTrigger> </ControlTemplate.Triggers>