D
D
Daniel Demidko2019-02-21 12:58:48
.NET
Daniel Demidko, 2019-02-21 12:58:48

How to make the figure not climb out of the frame during transformations?

I am writing a small WPF application. It is necessary that inside the frame (Border) there is a figure (for example, Rectangle), to which certain transformations could be applied (for example, rotation by 30 degrees).
Everything worked out, but only when the figure is rotated, it goes beyond the borders of the frame.
How to fix it?
5c6e76189e4d2477989743.jpeg

partial class AbstractShape : Border
{
    public AbstractShape(in Shape shape)
    {
        InitializeComponent();
        Child = shape;
    }
}

What is the problem, as I see it: By default, the shape has the Fill property, that is, filling the entire available area, but instead of being distorted itself, it prefers to crawl out of the frame.
If I stretch the frame itself in height and width after rotating the figure, then the figure will also resize accordingly and pop out again.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Developer, 2019-02-21
@DanielDemidko

When rotating, you also need to change the scale of the figure. And the scale itself depends on the angle of rotation, i.e. it will be a function of the angle.
Once upon a time, I did something similar, only on canvas

G
GrWizard, 2019-05-07
@GrWizard

Do not Render transformation, but Layout

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question