WPF Height / Width

In a WPF user control, I would like to set the width of the control as a function of height. For instance:Width = Height / 3 * x;

What would be the best way to accomplish this so that the control resizes (and initially resizes) correctly and smoothly?

+3
source share
1 answer

You can bind Widthto ActualHeightand use converter to apply a custom function. For instance. The following code always makes the button squared:

<Button Width="{Binding ActualHeight, RelativeSource={RelativeSource Self}}"/>

Hope this helps,

Greetings, Anwaka.

+10
source

Source: https://habr.com/ru/post/1734094/


All Articles