如何将StackPanel
设置为StackPanel
个孩子,取决于<StackPanel Orientation="Horizontal">
<Button Content="Q" />
<Button Content="W" />
<Button Content="E" />
<Button Content="R" />
<Button Content="T" />
<Button Content="Y" />
<Button Content="U" />
<Button Content="I" />
</StackPanel>
方向,例如,Orientatioin是水平的,然后设置边距0,0,10,0或方向是垂直的设定保证金0,10,0,0。
我试着找到任何想法,但直到现在我找不到任何东西,你能帮助我吗?
由于
编辑:
spring.jackson.serialization.fail-on-empty-beans=false
答案 0 :(得分:0)
试试这个。
<StackPanel Name="stack" Orientation="Horizontal">
<StackPanel.Resources>
<Style TargetType="{x:Type Button}">
<Setter Property="Margin" Value="0,0,0,10"/>
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=stack, Path=Orientation}" Value="Horizontal">
<Setter Property="Margin" Value="0,0,10,0" />
</DataTrigger>
</Style.Triggers>
</Style>
</StackPanel.Resources>
<Button Content="Q" />
<Button Content="W" />
<Button Content="E" />
<Button Content="R" />
<Button Content="T" />
<Button Content="Y" />
<Button Content="U" />
<Button Content="I" />
</StackPanel>