miroiu / nodify

Highly performant and modular controls for node-based editors designed for data-binding and MVVM.
https://miroiu.github.io/nodify
MIT License
1.38k stars 224 forks source link

[Question]Connection line display issue #130

Open MachineVisionxiaotan opened 3 months ago

MachineVisionxiaotan commented 3 months ago

This is my first time testing the Nodify library. When I add two nodes and place them in the editor, if there is a certain distance between them in the x direction, the connection line will not appear if I try to connect them directly without dragging the nodes first. Only after dragging the nodes will the connection line be displayed,what is the reason for this?

miroiu commented 3 months ago

Does the following answer help you? https://github.com/miroiu/nodify/wiki/FAQ#q-why-is-the-connection-not-following-the-connectors-when-i-move-a-node

Also, make sure that the binding for the Anchor is set to OneWayToSource.

MachineVisionxiaotan commented 3 months ago

I have already set Anchor OneWayToSource. I found that the issue of not displaying only occurs when the y coordinates of the two nodes are the same

miroiu commented 3 months ago

I can't reproduce it. Can you give me more details?

MachineVisionxiaotan commented 3 months ago

https://github.com/user-attachments/assets/7e872d09-7904-45a6-9428-83ba362f52d8

Video is the effect. Initial positions of two nodes: Location=new System.Windows.Point(200, 200), Location = new System.Windows.Point(500, 200),

miroiu commented 3 months ago

It works fine for me. There must be something wrong with your setup.

Please verify that:

  1. the collection that stores the connections is observable or at least raise a PropertyChanged event when a connection is added.
  2. the Source and Target are bound to the corresponding connector Anchor in the Connection template/style
  3. the Anchor is bound in a OneWayToSource mode to the corresponding connector Anchor in NodeInput and NodeOutput
  4. the connector class is implementing INotifyPropertyChanged and the Anchor property raises PropertyChanged events

Also worth checking out: https://github.com/miroiu/nodify/wiki/Getting-Started#a-minimal-example

Move the viewport top-left a bit to check whether the connection is correctly added to the graph (it is added at 0, 0). If the Anchor binding has problems, you will see something like this:

image

MachineVisionxiaotan commented 3 months ago

It's not related to binding, it just doesn't display when horizontal

https://github.com/user-attachments/assets/74991790-5f53-4025-b395-4a411263b20f

MachineVisionxiaotan commented 3 months ago

The reason is that I wrote SourceOffsetMode="Rectangle" TargetOffsetMode="Rectangle",delete them and everything will be fine. image