wpf 中的用户控件列表错误

error with list of usercontrol in wpf

我创建了一个带有多个用户控件的 wpf 应用程序,其中一个我想要另一个用户控件的列表,我使用了可管理的可观察集合,但是当我在设计器中将项目添加到此列表并构建解决方案时,用户控件消失并显示错误。

Cannot create an instance of " Component".

异常: 无法创建“组件”的实例。

错误: 组件项目。 Component' 没有由 URI '/Project;component/component.xaml'.

标识的资源

我创建了 observableCollection,如果我创建了 observableCollection,问题就解决了,但我需要收集我的 userControl。 当我 运行 应用程序时我没有问题,只在设计器中出现问题。

已编辑:

   public partial class my_Component : UserControl
    {

        private ObservableCollection<user_Component> userCollection;
        public ObservableCollection<user_Component> UserCollection
        {
            get { return userCollection; }
        }
        public my_Component()
        {
            userCollection = new ObservableCollection<user_Component>();
        }


In xaml:
    <cc:my_Component >
        <cc:my_Component.userCollection>
            <cc:user_Component/>
        </cc:my_Component.userCollection>
    </cc:my_Component>

这个问题通过使用 ObservableCollection 的 'DependencyProperty' 解决了。