Construyendo un StackPanel reversible en WPF

Me gustaría construir una costumbreStackPanel con unReverseOrder propiedad que puedo establecer declarativamente en true para que los elementos en el StackPanel aparezcan en el orden opuesto de lo normal (por ejemplo, de abajo hacia arriba o de derecha a izquierda). Tiene que ser reversible sobre la marcha.

Estoy pensando en derivar una nueva clase de StackPanel, pero necesito saber qué métodos anular.

Solución final:

protected override System.Windows.Size ArrangeOverride( System.Windows.Size arrangeSize ) {
    double x = 0;
    double y = 0;

    IEnumerable<UIElement> children = ReverseOrder ? InternalChildren.Cast<UIElement>().Reverse<UIElement>() : InternalChildren.Cast<UIElement>();
    foreach ( UIElement child in children ) {
        var size = child.DesiredSize;
        child.Arrange( new Rect( new Point( x, y ), size ) );

        if ( Orientation == Orientation.Horizontal )
            x += size.Width;
        else
            y += size.Height;
    }

    if ( Orientation == Orientation.Horizontal )
        return new Size( x, arrangeSize.Height );
    else
        return new Size( arrangeSize.Width, y );
}

También define y registraReverseOrder&nbsp;y llamaUpdateLayout&nbsp;si cambia