这里指出:
-
Your custom class must be public and support a default (parameterless) public constructor. (See following section for notes regarding structures.)
-
Your custom class must not be a nested class. Nested classes and the "dot" in their general CLR usage syntax interfere with other WPF and/or XAML features such as attached properties.
另外,在无参数的构造函数内,要确保有InitializeComponent();一句。而它会生成
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
System.Uri resourceLocater = new System.Uri("/CdcSoftware.Erp.Shared.ClientUI;component/controls/virtualizationgrid.xaml", System.UriKind.Relative);
#line 1 "..\..\..\Controls\VirtualizationGrid.xaml"
System.Windows.Application.LoadComponent(this, resourceLocater);
#line default
#line hidden
}
这样的语句,才能把xaml给加载进来。