[英]Best way to transfer data from View to complex controls
I am building a control heavy application in wpf and I am trying use the best solution for various views (in terms of maintainability, scalability, etc). 我正在wpf中构建一个控制繁重的应用程序,并且我尝试针对各种视图(就可维护性,可伸缩性等)使用最佳解决方案。
Eg If I have a control on a main view and I want to bind data between them I use a dependency property. 例如,如果我在主视图上有一个控件,并且想在它们之间绑定数据,则可以使用依赖项属性。
My question is what is the best tool to use if I have a control (lets call it PaneControl) on a view (call it MainView), which itself contains a control (call it BasicControl) with a property on it which I want to pass to the main view. 我的问题是,如果我在视图(称为MainView)上有一个控件(叫它PaneControl),它本身包含一个控件(称它为BasicControl),并且它具有要传递的属性,那么使用的最佳工具是什么?到主视图。
Is there a way of passing the property from the BasicControl to the MainView without sending a command to PaneControl and then sending another command to MainView? 有没有一种方法可以将属性从BasicControl传递到MainView,而无需将命令发送给PaneControl,然后再将另一个命令发送给MainView?
Best way to transfer data from view to complex controls would be still Binding ElementName. 从视图向复杂控件传输数据的最佳方法仍然是Binding ElementName。
Here is a link to a page that explains how to use Binding ElementName. 这是指向页面的链接,该页面解释了如何使用绑定ElementName。
http://msdn.microsoft.com/en-us/library/system.windows.data.binding.elementname%28v=vs.110%29.aspx http://msdn.microsoft.com/zh-cn/library/system.windows.data.binding.elementname%28v=vs.110%29.aspx
If ElementName is not what you looking for then maybe x:Reference will help you out. 如果不是您想要的ElementName,那么x:Reference可能会帮助您。
Take a look at this link: 看一下这个链接:
http://msdn.microsoft.com/en-us/library/ee795380%28v=vs.110%29.aspx http://msdn.microsoft.com/zh-CN/library/ee795380%28v=vs.110%29.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.