[英]error with list of usercontrol in wpf
I create a wpf app with several UserControls and in one of them I want have a list of another usercontrol, I used from observable collection that manage easy it but when I add item to this list in designer and build solution, user control gone and show error. 我用几个UserControl创建了一个wpf应用程序,其中一个我想要一个其他usercontrol的列表,我从可观察的集合中使用它来管理它很容易,但是当我在设计器中将项目添加到此列表中并构建解决方案时,用户控件就消失了错误。
Cannot create an instance of " Component". 无法创建“组件”的实例。
Exception: Cannot create an instance of " Component". 例外: 无法创建“组件”的实例。
errors: The component Project. 错误: 组件项目。 Component' does not have a resource identified by the URI '/ Project;component/component.xaml'. 组件”没有URI“ / Project; component / component.xaml”标识的资源。
I create observableCollection and if I create observableCollection problem be solved but I need to collection of my userControl. 我创建了observableCollection,如果创建了observableCollection,则可以解决问题,但需要收集userControl。 When I run app I haven't problem and only in designer problem occurred. 当我运行应用程序时,我没有问题,只有设计器问题发生了。
Edited: 编辑:
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.