将 Bezier 线段或线的端点绑定到 WPF 中的其他形状?
我正在尝试创建类似 UDK 或 Maya 材质编辑器的东西 http://www.google.com/search?q=udk+material+editor&oe=utf-8&rls=org.mozilla:en-US:official&cli ent=firefox-a&um=1&ie=UTF-8&hl=en&tbm=isch&source=og&sa=N&tab=wi&biw=1144&bih=929其中,可以通过单击一个连接并将其拖动到另一个节点来连接两个节点。 WPF可以做到这一点,但我不知道如何以编程方式(使用 C#,而不是 XAML)绑定贝塞尔曲线的端点和控制点以遵循周围的两个节点连接。有一些用 WPF 制作的流程图,但没有一个真正有帮助(尤其是免费的)。
感谢您的帮助。非常非常感谢!
I am trying to create something like the UDK or Maya material editor http://www.google.com/search?q=udk+material+editor&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a&um=1&ie=UTF-8&hl=en&tbm=isch&source=og&sa=N&tab=wi&biw=1144&bih=929 where two nodes can be connected by clicking and dragging one connection to another. WPF can do this, but I don't know how to programatically (with C#, not XAML) bind the endpoints and control points of a bezier curve to follow the two node connections around. There are flow charts out there made with WPF, but none that have really helped (especially the free ones.)
Thanks for any help. It is much, much appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最简单的方法是让包含表示端点的数据的对象具有返回几何图形(带有数据的贝塞尔曲线表示形式)的属性 getter,
然后将 Path 对象的 Data DependencyProperty 绑定到该属性,
然后当点更改,只需引发一个 PropertyChanged 事件(您的对象需要实现 INotifyPropertyChanged),这将导致绑定更新,
这将导致获取 Geometry 属性,然后返回一个表示当前值的新 Geometry 目的。
The easiest way is for the object that contains the data representing the end points to have a property getter that returns a Geometry (with the bezier representation of the data)
Then bind the Data DependencyProperty of a Path object to that property,
Then when the points change, simply raise a PropertyChanged event (your object need to implement INotifyPropertyChanged) which will cause the binding to be updated,
This will cause a get on the Geometry property which can then return a new Geometry representing the current values in the object.