【发布时间】:2010-06-05 19:18:55
【问题描述】:
我正在学习 WPF,但不知道如何使我的按钮变成方形。
这是我的 XAML 标记:
<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>
为Width 和Height 属性指定显式值似乎是一个错误的想法——按钮应该根据其内容自动计算其尺寸,但保持其宽度和高度相等。这可能吗?
【问题讨论】: