使用MVVM模式连接(带线)两个UI元素 [英] Connect (with line) two UI elements using MVVM pattern

查看:94
本文介绍了使用MVVM模式连接(带线)两个UI元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始在WPF中使用MVVM模式.我有一个ViewModel类的集合,这些类以UIElements(即矩形)的形式显示在屏幕上,我希望能够在这些元素之间绘制线条以将它们连接起来.事实是,该行还表示另一个ViewModel对象.现在,我已经能够在屏幕上显示静态尺寸的线,但是我希望能够单击按钮或菜单项或其他东西,然后从一个矩形到另一个矩形绘制一条线,然后在矩形"处进行连接"同时创建一个表示该连接的viewmodel类.该连接还应该知道其连接的内容(例如开始/结束视图模型).

有人可以帮我吗?

解决方案

WPF图表设计器:第1部分

WPF图设计器-第2部分

WPF图表设计器-第3部分

WPF图表设计器-第4部分


Hi, I''ve recently started using the MVVM pattern in working with WPF. I have a collection of ViewModel classes which are displayed on the screen as UIElements (namely rectangles) and I want to be able to draw lines between these elements to connect them. The thing is that the line also represents another ViewModel object. now i''ve been able to get static sized lines to appear on the screen, but I want to be able to click a button or menuitem or something and draw a line from one rectangle to another and have them "connect" while at the same time create a viewmodel class that represents that connection. The connection should know what it''s connecting also (e.g. start/end viewmodels).

Can anyone help me?

解决方案

NetworkView: A WPF custom control for visualizing and editing networks, graphs and flow-charts

WPF Diagram Designer: Part 1

WPF Diagram Designer - Part 2

WPF Diagram Designer - Part 3

WPF Diagram Designer - Part 4


这篇关于使用MVVM模式连接(带线)两个UI元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆