WPF dynamic layout: how to enforce square proportions (width equals height)?
Posted
by Gart
on Stack Overflow
See other posts from Stack Overflow
or by Gart
Published on 2010-06-05T19:18:55Z
Indexed on
2010/06/05
19:22 UTC
Read the original article
Hit count: 1245
I'm learning WPF and can't figure out how to enfore my buttons to take a square shape.
Here is my XAML Markup:
<Window x:Class="Example"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="368" Width="333">
<Window.Resources>
<Style x:Key="ToggleStyle" BasedOn="{StaticResource {x:Type ToggleButton}}"
TargetType="{x:Type RadioButton}">
</Style>
</Window.Resources>
<RadioButton Style="{StaticResource ToggleStyle}">
Very very long text
</RadioButton>
</Window>
Specifying explicit values for Width
and Height
attributes seems like a wrong idea - the button should calculate its dimensions based on its contents automagically, but keep its width and height equal. Is this possible?
© Stack Overflow or respective owner