繁体   English   中英

wpf中的usercontrol列表错误

[英]error with list of usercontrol in wpf

我用几个UserControl创建了一个wpf应用程序,其中一个我想要一个其他usercontrol的列表,我从可观察的集合中使用它来管理它很容易,但是当我在设计器中将项目添加到此列表中并构建解决方案时,用户控件就消失了错误。

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

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

错误: 组件项目。 组件”没有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'解决了此问题。

暂无
暂无

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

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