views:

66

answers:

1

I need a custom border that renders a little differently than a normal border. I made a class that inherited from Decorator as follows

class BetterBorder : Decorator
{
    protected override Size ArrangeOverride(Size arrangeSize)
    {
        return arrangeSize;
    }

    protected override void OnRender(DrawingContext dc)
    {
        //these values are calculated elsewhere
        dc.DrawGeometry(backgroundBrush, borderPen, pathGeometry);
    }
}
//Properties and helper methods below this

All of this works fine until I try to add a child to the control, the control can be added but is not visible and seems to be moved off BetterBorders visible client area. If I inherit from Border everything works fine, what am I missing?

A: 

Easily fixed by making sure you call the base implementation of ArrangeOverride

protected override Size ArrangeOverride(Size arrangeSize)
{
    base.ArrangeOverride(arrangeSize);
    return arrangeSize;
}
galacticgrug