How do I change the content position on a DiagramConnection?
I tried using ContentPosition.Offset but that didn't seem to do anything.
I have a Rhombus (workflow decision) shape and I want the content of the connection that loops back to another DiagramNode to appear next to the Rhombus and not centered on the DiagramConnection.
Basically, how would I do that... in .Net code (not XAML).
Example code I have:
StepConnection = New Infragistics.Controls.Charts.DiagramConnection
StepConnection.StartNode = EndLoopNode
StepConnection.StartNodeKey = EndLoopNode.Name
StepConnection.StartNodeConnectionPointName = "Left"
StepConnection.EndNode = BeginLoopNode
StepConnection.EndNodeKey = BeginLoopNode.Name
StepConnection.EndNodeConnectionPointName = "Left"
StepConnection.Content = "Yes"
Hello,
I have been looking into your enquiry and even though there is no built-in functionality for moving the content along the connection line, there is a way to show additional information at the line end. I can suggest using the restyling functionality of the connection caps and retemplate it to display the needed data as shown here in the online documentation: http://help.infragistics.com/Help/Doc/WPF/2014.2/CLR4.0/html/xamDiagram_Configuring_the_Caps_of_Diagram_Connections.html#_Ref386478056
Please let us know, if you need any further assistance on the matter.
That is an answer I suppose. But, that comes with a few problems for our needs. We are generating the diagram dynamically (runtime) and I need to create the display templates in code not xaml.
Also, some of the diagrams could also be large diagrams. Thus, the performance would be impacted if I used custom templates for the caps.
This is taken from your (Infragistics) optimization tips for the xamDiagram:
Connection caps
Custom caps set through the DiagramConnection.StartCapStyle and EndCapStyle properties attach a new control in the visual tree for each cap. For data intensive applications, consider using one of the predefined cap types through the DiagramConnection.StartCapType and EndCapType. If possible do not use caps at all by setting the cap type to None.
I'm guess this will be a similar response for my next question about adjusting the right angle (length of straight line from node). The right angles are very close to the nodes they connect and do not leave a lot of room for text. Even the text that is displayed as the content now runs into nodes that are near the connector line as it passes near them. So, to alleviate that, there needs to be some way to change the connector (bounds) dynamically I suppose. But, even when I try to move a connector "manually" on the diagram and then try to "reconnect" the connection points it keeps resizing it back to the original distance (of the angles) when I reconnect the 2 nodes. Maybe that's a bug?
I also have an issue of connectors overlapping or appearing on top of each other. The only way I can alleviate that is to loop through every object to see if another object is contained or intersects. Is there an easier way to do that? I already have my own custom IDiagramLayout that handles most of the normal layout, but, the ability to avoid collisions or positioning objects so they do now hide other objects is proving to be a challenge with the way the nodes and connectors are implemented.
Hi,
I am really glad to hear, you have found a solution for your requirement. Thank you for updating the forum thread with the information.
Thanks for the response. I decided to go a different route that better suits our particular needs for dynamic chart creation. I handle everything in my custom layout class.
I see what you mean and yes, you are right – the templates will indeed impact your performance. Nevertheless I created a test style for you that solves both the text reaching inside the nodes and the right angle issues, using the LineOffset and PlacementOffset properties:
<Style TargetType="ig:DiagramConnectionCapPresenter"
x:Key="capStyle">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=RenderTransform.Angle}"
Value="180">
<Setter Property="LayoutTransform">
<Setter.Value>
<RotateTransform Angle="180" />
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
<Setter Property="LineOffset"
Value="{Binding RelativeSource={RelativeSource Self}, Path=ActualWidth}" />
<Setter Property="PlacementOffset"
Value="{Binding RelativeSource={RelativeSource Self}, Path=ActualWidth, Converter={StaticResource con}}" />
<Setter Property="UseRotation"
Value="True" />
<Setter Property="Template">
<ControlTemplate>
<TextBlock Padding="2" Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ig:DiagramConnection}}, Path=Content}" />
</ControlTemplate>
</Style>
it also has a trigger adjusting the rotation so that your text doesn’t end up upside-down.
Regarding the single connection points being used by multiple connections, there is no built-in functionality for dynamically creating exclusive connection points, however you can define and use your own as described here: http://help.infragistics.com/doc/WPF/2014.2/CLR4.0/?page=xamDiagram_Connections_Connection_Points.html
Please let me know, if I can help with anything else.