【发布时间】:2015-07-31 19:55:35
【问题描述】:
我希望子元素之间的空间,例如 StackPanel 是相同的。当对子元素使用相同的 Margin 时,邻居之间的差距会加倍。我正在使用一个小技巧来解决这个问题,但在我看来,还有更优雅的解决方案。你有吗?
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="MyButtonStyle" TargetType="Button">
<Setter Property="Margin" Value="4,4,0,4" />
...
</Style>
<Style x:Key="LastMyButtonStyle" TargetType="Button" BasedOn="{StaticResource MyButton}">
<Setter Property="Margin" Value="4" />
</Style>
我对所有按钮都使用 MyButtonStyle,除了最后一个,它使用 LastMyButtonStyle。
【问题讨论】:
标签: wpf mono styles margin space