Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/EmptyTag/146.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 4.0 Silverlight用户控制问题_C# 4.0_Silverlight 5.0 - Fatal编程技术网

C# 4.0 Silverlight用户控制问题

C# 4.0 Silverlight用户控制问题,c#-4.0,silverlight-5.0,C# 4.0,Silverlight 5.0,我正在尝试创建一个Repeater模板用户控件,即一个矩形边框包含一行UIElements,如TextBox、ComboBox等,然后我会自动在该行末尾添加一个+按钮。单击+按钮,我想在其下方添加相同的重复行 这是使用用户控件的语法: <RepeaterTemplate> <RepeaterTemplateItem> <TextBox /> <ComboBox /> </RepeaterTemplateItem> </

我正在尝试创建一个Repeater模板用户控件,即一个矩形边框包含一行UIElements,如TextBox、ComboBox等,然后我会自动在该行末尾添加一个+按钮。单击+按钮,我想在其下方添加相同的重复行

这是使用用户控件的语法:

<RepeaterTemplate>
 <RepeaterTemplateItem>
  <TextBox />
  <ComboBox />
 </RepeaterTemplateItem>
</RepeaterTemplate>
代码隐藏:

RepeaterLayoutItem:

公共网格RepeaterRow{get;set;} 公共列表LayoutItemCollection{get;set;}

//在+按钮上单击处理程序:

RepeaterLayoutItem duplicate=this.memberWiseClone; LayoutItemCollection.Addduplicate

中继器布局: 公共可观测集合子项{get;set;} 公共网格RepeaterContentGrid{get;set;}

foreachRepeaterLayoutItem在子项中 { 网格重复行=item.RepeaterRow

RepeaterContentGrid.Children.AddduplicateRow;//这里给出的错误元素已经是+按钮单击时其他元素的子元素

}

我也尝试过使用iClonable接口,但仍然存在相同的问题

如果我使用memberWiseClone复制行,在添加重复行时仍会出现相同的错误。可能是克隆的重复行中父属性的非空值的原因

我不知道如何让这个功能正常工作。请帮忙

谢谢,
GK Prajapati

你能显示创建和添加新行的代码吗?对问题进行了编辑,显示了代码。你看过我在这篇文章的评论中提供的示例吗?memberWiseClone来自哪里?