Instead of the ScaleTransform you could use a MatrixTransform that scales by -1 in y direction and translates the coordinate origin to the control's center. This transform must however be updated whenever the control's size changes. Hence you would override OnRenderSizeChanged like below (assuming that you set the RenderTransform
property of your control):
protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
{
base.OnRenderSizeChanged(sizeInfo);
RenderTransform = new MatrixTransform(1d, 0d, 0d, -1d,
sizeInfo.NewSize.Width / 2d, sizeInfo.NewSize.Height / 2d);
}
EDIT: In case you don't want to transform the whole controls, you could also define a MatrixTransform as class member and apply it to every Visual in the visual children collection.
private MatrixTransform transform = new MatrixTransform();
Assign to the Transform property of every new Visual:
ContainerVisual visual = ...
visual.Transform = transform;
On size changes you would simply update that MatrixTransform:
protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
{
base.OnRenderSizeChanged(sizeInfo);
transform.Matrix = new Matrix(1d, 0d, 0d, -1d,
sizeInfo.NewSize.Width / 2d, sizeInfo.NewSize.Height / 2d);
}
Of course you only need to apply the Transform to "top-level" visuals. Children of those visuals will be transformed by the Transform of their parents. I do not exactly understand how you manage your visuals by a "Border subclass that contains a VisualCollection". The typical approach would be to have one parent ContainerVisual as root of the visual tree. Transforms would then be applied to this root visual only.