Hide Link(s) and Node(s)

What is the right way to hide link or node?

I was able to hide the link by adding binding to the Visibility property of the LinkPanel in the link’s DataTemplate but I think it will be better to change the Visibility of the Link itself and not its DataTemplate. The same for Node.

I’ve try to create the following styles but it did not work for me:

<Style TargetType="{x:Type go:Link}">

<Setter Property="Visibility" Value="{Binding Data.IsVisible, Converter={uifx:DefaultConverters uifx:BoolToVisibilityConverter}}" />


<Style TargetType="{x:Type go:Node}">

<Setter Property="Visibility" Value="{Binding Data.IsVisible, Converter={uifx:DefaultConverters uifx:BoolToVisibilityConverter}}" />


Thank you,


That’s right. That’s why you should set or data-bind the go:Part.Visible attached property. It automatically changes the value of Visibility appropriately. It’s also a boolean, so you don’t need to bother with converters.

I see, so the reason for the existence of the Visible attached property is to put it on the root visual element of the part template. Thank you.

Hello Walter,
I’ve successfully use go:Part.Visible on my node DataTemplate top visual element and the nodes are hide and show just right.
I fail to do so with Link DataTemplate.
I’ve add go<span =“s1”>:Part.Visible<span =“s1”>=“False” to the PipeTemplate in the Piping demo and the links are still there.
<span =“s1”>Setting the Visibility to Collapsed does the trick but I would like to be consistence with my templates.
<span =“s1”>

<span =“s1”>Thank you,
<span =“s1”>Ido.

That appears to be a bug. Try replacing the Diagram.PartManager with a custom one that overrides this method as follows:

protected override void OnLinkAdded(Link link) {
  if (link == null) return;
  Diagram diagram = this.Diagram;
  if (diagram == null) return;
  bool vis = true;
  Group sg = link.ContainingSubGraph;
  if (sg != null && (!sg.Visible || !sg.IsExpandedSubGraph)) vis = false;
  if (vis) {
    Node from = link.FromNode;
    if (from != null && FindVisibleNode(from) == null) vis = false;
  if (vis) {
    Node to = link.ToNode;
    if (to != null && FindVisibleNode(to) == null) vis = false;
  if (!vis && link.Visible) link.Visible = false;
  InvalidateLayout(link, LayoutChange.LinkAdded);

private Node FindVisibleNode(Node n) {
  while (n != null && n.Visibility != Visibility.Visible) {
    n = n.ContainingSubGraph;
  return n;

private void InvalidateLayout(Part part, LayoutChange why) {
  // no side-effects during undo/redo
  IDiagramModel model = part.Model;
  if (model == null || model.IsChangingModel) return;
  Diagram diagram = part.Diagram;
  if (diagram == null) return;
  LayoutManager mgr = diagram.LayoutManager;
  if (mgr != null) mgr.InvalidateLayout(part, why);

I’m trying it and let you know how it worked.

Thank you,

It did not solve the problem.
I think the problem is somewhere else.
I’m looking at the code with Reflector and you did great job of obfuscating it so I don’t have the exact method names, but Part class has internal abstract method that accept bool name vis. and Node class override this method and in some condition set the Visible attached property of the links attached to the node even though the bounded property had false in it the Visible attached property was true and the link was visible on the diagram.

I understand that the problem is that when a node is hidden it links should be hidden to - but if you put local value to Visible attached property it will override any bounded value, I think.

Are you trying to make a Link visible when either or both of the nodes it connects are not visible? That’s not the normal policy.

If so, perhaps the order matters – maybe the Link is in fact visible initially, but then making a connected node not visible causes the link to be made invisible.

In my data class of both nodes and links I have a boolean property name IsVisible. In my nodes and link DataTemplate I have the following binding:

go:Part.Visible="{Binding Data.IsVisible}"

On the root visual element.

Inside my application code I change the IsVisible property according to some logic.

The Visible binding works great on the nodes but does not work on the links.

I've change the binding on the link root visual element like so:

Visibility="{Binding Data.IsVisible, Converter={StaticResource BoolToVisibilityConverter}}"

which works as expected but does not use the Visible attached property.

I’m checking to see if there is any progress on the bug in Link.Visible not working right?

Thank you,

Not at the moment. I thought everything was working OK for you.

I have found a workaround by using the Visibility of the root visual element in the link data template.
The problem is that when we hide the links, move the nodes around and reshow the links sometime (I can’t repro it consistently yet) some links remain where the nodes where when we hide them.
I thought maybe there is a connection to the workaround we use to hide the links.

I was wondering if this issue has been fixed in the last beta release?

Thank you

I’m not sure which issue you are talking about.

The Visible/Visibility bug I mentioned earlier has been fixed in version 1.3.

However, I have no idea about what bug, if any, you are referring to in your most recent posts.
I suggest you try the beta DLL with and without the work-around code in the PartManager that I suggested.

Thank you. I was referring the bug that Visible of Link does not hide it when set to false.

I’ll give it a try.

Thank you,

I’ve include the new beta DLL and it looks like the bug with the links that did not hide when set Visible to false has been fixed.


That’s good to hear.

I was to quick to celebrate I’m afraid.
I can’t reproduce the problem in small project, yet, but I did find that when I bind both my node’s DataTemplate first element with go:Part.Visible={Binding Data.IsVisible} and also bind my link’s DataTemplate first element with go:Part.Visible={Binding Data.IsVisible} the links are not hide when the data of the link turn IsVisible to false.

Both my node data and link data class have plain-old-clr-property name IsVisible, with call to OnPropertyChanged.

When I remove the binding of the Part.IsVisible from the node DataTemplate the links are hide just fine. I looks like the binding between the link’s VisualElement (first element in the link’s DataTemplate) is removed and a local value of true is set to Part.Visible attached dependency property, but I still don’t know why.

Thank you and I hope I’ll have more information soon.

I think the problem is that the normal visibility propagation that is performed is setting the Part.Visible property, thereby displacing the data binding that was established in the template.

Try making all those bindings Mode=TwoWay.

Thank you very much again walter for saving the day (more like the month with this issue).
If you can help me understand why binding both node and link DataTemplate Part.Visible properties fix the problem that cause the link’s Visible property to be always true it will be very nice.

Any way, both links and node are now visible and hidden appropriately.

Thank you,