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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’m not sure this will work, but if you register a handler for the
SizeChangedevent and in there put in your code keep the aspect ratio 1:1.The
SizeChangedEventArgsargument 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
SizeChangedevents as a result of updating theHeightorWidth.