Custom property descriptor in .net

523 Views Asked by At

I am using the PropertyGrid from extended wpf tool kit.

There is a requirement to implement localization for property grid. To achieve this , a base class implements ICustomTypeDescriptor and another class that implements PropertyDescriptor.

I am able to localize property grid. But there is a problem associated.

1) If a base class implements ICustomTypeDescriptor , and suppose if derived class has a property name(an overridden property) same as of base class, an exception is thrown.

BaseClass :

    [Category("Font")]
    [DisplayName("PROPGRID_FONTALIGN")]
    public virtual TextAlignment FontAlign
    {
        get
        {
            if (CrControl.FontAlign == "Left")
                return TextAlignment.Left;
            if (CrControl.FontAlign == "Right")
                return TextAlignment.Right;
            if (CrControl.FontAlign == "Center")
                return TextAlignment.Center;
            return TextAlignment.Justify;
        }
        set
        {
            CrControl.FontAlign = value.ToString();
            SetProperty(ref _fontAlign, value);
        }
    }

Derived Class:

    [Browsable(false)]
    public override TextAlignment FontAlign
    {
        get { return base.FontAlign; }
        set { base.FontAlign = value; }
    }
0

There are 0 best solutions below