Question

I've got a custom control that draws a graph. A new requirement has arrived, and one part of a solution is rotating the graph. There are other changes inside the control, but these are relatively simple and won't affect this issue.

I can rotate the control as follows:

protected override void OnRender(DrawingContext drawingContext)
{
    base.OnRender(drawingContext);

    InitStandard();
    drawXaxis();
    drawYaxis();
    drawZAxis();

    Titles();

    Generate();

    drawGridLines();


    if (UsedAxisType == AxisType.FloorPlot)
    {
        gdRootGrid.RenderTransformOrigin = new Point(.5, .5);
        gdRootGrid.RenderTransform = new RotateTransform(90);
    }

}

This rotates with no problem - I now need to change the width & height of the control to match the new dimensions created with the rotate. I can't do that here as setting the width & height of the control in this event causes a rendering loop.

How do I do this properly?

Was it helpful?

Solution

Try

gdRootGrid.LayoutTransform = new RotateTransform(90);

instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top