Hello,
Does anyone have an idea how to keep the Height/Width Ratio 1:1 of a UserControl? E.g. if Height > Width, Width & Height will have the same size and vice versa.
Thanks for any help.
Cheers
Hello,
Does anyone have an idea how to keep the Height/Width Ratio 1:1 of a UserControl? E.g. if Height > Width, Width & Height will have the same size and vice versa.
Thanks for any help.
Cheers
I'm not sure this will work, but if you register a handler for the SizeChanged
event and in there put in your code keep the aspect ratio 1:1.
The SizeChangedEventArgs
argument has the old size and the new size so you can check which has changed and update the other accordingly.
You might need to introduce a guard variable so that you don't get a cascade of SizeChanged
events as a result of updating the Height
or Width
.