Links not always seen

Thank you for your help I currently try to implement a specific algorithm that works for my scenario. I got another question. Within some zoom steps parts of my links go missing. It seems to be a problem of antialiasing, which only occurs when I´m using lines. Can you help me how I’m able to avoid this situation?

Thank you very much!



When this situation occurs, what are the Diagram.Panel.Scale and the Link.Path.StrokeThickness? Does this only happen with orthogonal links? Does scrolling without changing scale cause the links to sometimes be shown and sometimes not?

It is the case that with lines that are effectively drawn much thinner than a pixel there is a chance that, depending on the sub-pixel positioning, the line will little representation or will not appear at all. You can easily see this effect in the Overview of the Org Chart (Static) sample.

These effects are implemented by WPF and are beyond our direct control. However you could try setting SnapsToDevicePixels=“True” on your Link Shape. I don’t know if that will help or not in your app.

SnapsToDevicePixels=“True” does not work. I also tried that. It seems so that the behavior depends on the position of the links and the specified zoom factor, whereby the scaling factor is always < 1. Is there an opportunity to round the Panel.Scale value, which is changed during the zooming process by using the mouse wheel? For example overwriting a tool or something else?

Yes you are right it only happen with orthogonal links.

I also observed missing lines within my text notice. Its linke the standard GoXam file figure but the bent corner does not resize. As a border I used rectangle elements. This rectangles sometimes be shown and sometimes not during scaling the diagram.

And increasing the StrokeThickness reduces the frequency at which the disappearance happens?

I think one could override DiagramPanel.OnScaleChanged to try to use only particular values for DiagramPanel.Scale, but I don’t know if we have ever tried that.

Yes increasing the StrokeThickness reduces the frequency at which the disappearance happens. How can I set my own diagram panel where I override DiagramPanel.OnScaleChanged, think Diagram.Panel is readonly (“get property”) and set by GoXam? In my point of view the problem with missing borders does not occures when I´m using your “File” figure. Maybe there is a solution which alos works from my text notice problem.

If you were to subclass DiagramPanel to override a method, you would need to set the Control.Template of your Diagram(s). The standard template is provided in the GenericWPF.xaml in the installation docs directory and in the Introduction document in the Appendix.

How are you defining that “text notice”?

Currently my text notice template looks like:

<go:NodePanel go:Node.LayerName=“Foreground” go:Node.PortId="{Binding Data.SdId}" go:Part.SelectionAdorned=“True” go:Part.Selectable=“True”
go:Part.Resizable=“True” go:Node.Location="{Binding Path=Data.Location, Mode=TwoWay}"
Height="{Binding Path=Data.Height, Mode=TwoWay}" SizeChanged=“OnSizeChanged”
Width="{Binding Path=Data.Width, Mode=TwoWay}" MinWidth="{Binding Path=Data.MinWidth}" Visibility="{Binding Path=Data.IsVisible, Mode=TwoWay}"
MinHeight="{Binding Path=Data.MinHeight}" ZIndex="{Binding Path=Data.ZIndex}" go:Part.Copyable=“False”>




<TextBlock Padding=“3” Text="{Binding Path=Data.Value, Mode=TwoWay}" TextWrapping=“Wrap” TextAlignment=“Left” FontFamily="{Binding Path=Data.FontFamily}"
FontStyle="{Binding Path=Data.FontStyle}" FontSize="{Binding Path=Data.FontSize}"
Foreground="{Binding Path=Data.ForegroundColor}" />

<Polygon Grid.Row=“0” Grid.Column=“3” Grid.ColumnSpan=“2” Grid.RowSpan=“2” Stretch=“UniformToFill” Points=“0 0 20 20 0 20” SnapsToDevicePixels=“True”
Stroke="{Binding Path=Data.Stroke}" StrokeThickness="{Binding Path=Data.StrokeThickness}"
Fill="{Binding Path=Data.Color}" />


The rectangles are at some zoom levels visible and at sone not, whereby not all borders (regtangles) are missing all the time.

Have you tried using the XAML of your template as regular XAML in a window? That way you could experiment without involving GoXam.

You would need to replace the bindings with hard-coded values which I don’t know, and then it would be nice to add a slider to control the scale of that panel in your window, if you don’t already have such control.

Also, although I haven’t actually tried your template, the go:NodePanel seems superfluous, since it only has one child element. You might be able to move its attributes down to the Grid and delete the NodePanel element, unless I am missing something.

I created a separate XAML file where the bindings are replaced by constant values:

<Window x:Class=“WpfApplication2.MainWindow”
Title=“MainWindow” Height=“350” Width=“525”>




Insert text here

I tried using your Grid with the hard-coded values as a NodeTemplate, and got the behavior that I think you are complaining about. When I changed everything to use SnapsToDevicePixels=“False”, no lines “disappeared”, but they were more likely to be gray because of anti-aliasing.

Yay, that works :) Think thats ok. Back to the links: Particular values for DiagramPanel.Scale does not work :(. The concept may work but missing of a link depends on the current scale level and its position or the position within the view port. I’m open to suggestions. Maybe increasing the link thickness during scaling works?

Yes, you could try scaling up the StrokeThickness as the DiagramPanel.Scale becomes smaller. You can do that in a DiagramPanel.ViewportBoundsChanged event handler, which you normally cannot declare until after the DiagramPanel is created by ControlTemplate application as the Diagram.Panel property, i.e. in a Diagram.TemplateApplied event handler.

Seems working! Thank you very much. I used 2 link templates and changed it depending on the specified scaling factor of the diagram