C# WPF中的构造函数ArgumentAttribute使用问题
我创建了一个自定义标记扩展,如下所示C# WPF中的构造函数ArgumentAttribute使用问题,c#,wpf,markup-extensions,C#,Wpf,Markup Extensions,我创建了一个自定义标记扩展,如下所示 public class CME: MarkupExtension { private Type _type; private string _typeName; public CME() { } public CME(Type type, string typeName) { this._type = type; this._typeName = typeName;
public class CME: MarkupExtension
{
private Type _type;
private string _typeName;
public CME()
{
}
public CME(Type type, string typeName)
{
this._type = type;
this._typeName = typeName;
}
[ConstructorArgument("type")]
public Type Type
{
get
{
return this._type;
}
set
{
this._type = value;
}
}
[ConstructorArgument("typeName")]
public string TypeName
{
get
{
return this._typeName;
}
set
{
this._typeName = value;
}
}
public override object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
}
我发现我仍然可以使用{local:CME{x:Type sys:Boolean},Bool}
在XAML中创建CME类的实例,即使我删除了CME类中的所有ConstructorArgumentAttribute
所以我想知道为什么在自定义标记扩展实现中需要ConstructorArgumentAttribute,或者ConstructorArgumentAttribute的含义是什么
有什么办法可以帮上忙吗?非常感谢