简体   繁体   English

尝试级联依赖项属性时的绑定错误

[英]Binding Error When Trying to Cascade Dependency Properties

So I have 4 UserControls on top of each other. 所以我彼此之间有4个UserControls。 Since I got confused a little, I got an image below: 由于我有点困惑,因此得到了以下图像:

在此处输入图片说明

The ViewModelLocator is in UserControl 1. The goal is to provide each UserControl with their own ViewModel. ViewModelLocator位于UserControl 1中。目标是为每个UserControl提供自己的ViewModel。 For UserControl 2 and 3, I managed to provide their ViewModels (for UserControl 3 I used a DependencyProperty). 对于UserControl 2和3,我设法提供了它们的ViewModel(对于UserControl 3,我使用了DependencyProperty)。 But for UserControl 4, I tried to cascade Dependency Properties lying in UserControl 2 and UserControl 3 to provide the ViewModel for UserControl 4. However I encountered an error: 但是对于UserControl 4,我试图级联位于UserControl 2和UserControl 3中的依赖项属性,以便为UserControl 4提供ViewModel。但是,我遇到了一个错误:

A 'Binding' can only be set on a DependencyProperty of a DependencyObject. 只能在DependencyObject的DependencyProperty上设置“绑定”。

What am I doing wrong? 我究竟做错了什么?

UPDATE: Below is a link to the archived copy of the sample solution that replicates this issue. 更新:以下是复制此问题的示例解决方案的存档副本的链接。

MvvmLight2.zip MvvmLight2.zip

Alright. 好的。 After a few hours looking at and playing with the code, I managed to make it work even with designer tool errors. 经过几个小时的研究和使用,我设法使它即使在设计师工具错误的情况下也能正常工作。 But why is it having errors even though it works? 但是,即使可以工作,为什么还会出错?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM