Selecting Node with TextBox in Template

Hi Walter,
I need your help!
I have a NodeTemplate with a TextBox in it. If I have a Diagram where I have two of this nodes, one is visible and the other is hidden and use DragSelectingTool I get 2 selected Nodes.
If I use a node with a Label in its Template and do the same things I get only one selected node, which is exact what I want.
I have many node templates all nearly the same, but with other controls in - but only the template with the TextBox behaves like this. I even changed it to a DevExpress TextEdit control and the TextEdit shows the same behavior as the TextBox.

I have no idea.

I’m sorry, but I don’t understand your situation, what is happening, and what you would prefer. Screenshots would help…

The gray one is a node with TextBox there are 3 other nodes on the same position that are not visible.
I get 4 selected nodes - which I don’t want.

The blue one is a Button control there are also 3 other node behind and not visible.
I get 1 selected node - which is what I want.

If those other three Nodes have Node.visible false, then they will not be selected by the DragSelectingTool.

If they are visible but just behind the node that we see in the screenshot, i.e. occluded by what we see, then they should be selected by the DragSelectingTool.

Why have multiple Nodes at the same location?

Oh, you sure remember I have some sort of great Layer-Structure and I could be that two nodes are located on different Layers but at the same position. I not use the layers of diagram. I managed this by setting visible.
Cause I found no reason why the Textbox should cause this I though it must be my code - but I can’t see the nodes that are selected (I tried to move the node - so that I must see the underlying node - but there is none) - and why is it working with the button template?

I will examine this further - thank you.

I still haven’t found where the problem is.
But I found that there are many properties on Part which have to do with the visibility:

Visibility - Gets or sets the user interface (UI) visibility of this element.
IsVisible - Gets a value indicating whether this element is visible in the user interface (UI).
Visible - Gets or sets whether the user may see or pick this part.
IsVisibleElement - This static predicate is true if the given elt’s Visibility is Visible and each of its visual parents are also visible elements, up to the containing Part.

I have bound my internal value for the visibility to the Visibility-Property of the Node.
I this right, or should I better bind to Visible?
What is the difference between all this Visible-Properties?

Also I found out that there is a difference between selecting with the DragSelectingTool and pressing Ctrl-a to select all,
The DragSelectingTool selects only visible (and invisible TextEdit) but the ctrl-a selects all node (visible or not).

Most people depend on the Part.Visible property, which is a boolean and which is more aligned with how people want to control “visibility”, since it’s actually an attached dependency property on the root element of the template.

What is with ctrl-a? Should this be “normal”?

I think you are agreeing that mouse-interactive tool operations should try to avoid dealing with not-Visible Nodes and Links. The question is whether the CommandHandler.SelectAll command should ignore not-Visible Parts.

I can see why you think the current behavior of the SelectAll command is inconsistent with the tools. However I believe that the thinking is that just because some Nodes and Links happen not to be visible does not mean that the user wouldn’t want to operate on them. Certainly that would be the case if the user afterwards wanted to delete or copy them all.

If you want to override the behavior, here is the standard implementation of that command:

    public virtual void SelectAll() {
      Diagram diagram = this.Diagram;
      if (diagram == null) return;
      try {
        diagram.Cursor = Cursors.Wait;
        foreach (Part p in diagram.Nodes) {
          p.IsSelected = true;
        foreach (Part p in diagram.Links) {
          p.IsSelected = true;
      } finally {
        diagram.Cursor = null;

Thank you for the code snippet.

I solved the problem of the TextEdit.
I am now considering the visibility in my IsSelectable Property.

public bool IsSelectable
    get { return Model != null && Model.EditMode && !IsPinned && Visibility == Visibility.Visible; }

Now the TextEdit gets not selected when it is invisible.