WPF dynamic layout: how to enforce square proportions (width equals height)?

后端 未结 4 558
长发绾君心
长发绾君心 2020-12-08 13:31

I\'m learning WPF and can\'t figure out how to enfore my buttons to take a square shape.

Here is my XAML Markup:



        
4条回答
  •  爱一瞬间的悲伤
    2020-12-08 13:54

    @Dan Pruzey's answer was good, but did not shrink the square if the window was downsized. What I found to work best was to set the height to auto and the width to that height:

    This kept the button a square when sizing my window bigger and smaller. Hope this helps someone.

提交回复
热议问题