我正在尝试使用以下内容创建自定义用户控件:
var panel = new GenericAccordionPanel<ZoneReport, ZonesPanel, ZonesVM>(myVm.ZonesVm);
GenericAccordionPanel
定义为:
public class GenericAccordionPanel<THeader, TBody, TViewModel> : UserControl
{
public Accordion Accordion { get; set; }
public GenericAccordionPanel(TViewModel vmItem)
{
this.Accordion = new Accordion();
//the constructor for ZoneReport(THeader) takes a ZonesVM (vmItem) as a parameter.
var zr = (THeader)Activator.CreateInstance(typeof(THeader), new { vmItem });
var exp = new Expander { Header = zr };
Accordion.Children.Add(exp);
base.Content = Accordion;
}
}
问题在于Activator.CreateInstance
以下情况失败MissingMethodException
:
未找到类型“[命名空间].Zones.ZoneReport”的构造函数。
我怎样才能创建一个实例ZoneReport
?