Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.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# WPF中的构造函数ArgumentAttribute使用问题_C#_Wpf_Markup Extensions - Fatal编程技术网

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的含义是什么

有什么办法可以帮上忙吗?非常感谢