How do I space out the child elements of a StackPanel?

前端 未结 11 2129
长情又很酷
长情又很酷 2020-12-04 06:11

Given a StackPanel:


  Apple
  Banana
  

        
11条回答
  •  被撕碎了的回忆
    2020-12-04 07:01

    +1 for Sergey's answer. And if you want to apply that to all your StackPanels you can do this:

    
        
    
    

    But beware: if you define a style like this in your App.xaml (or another dictionary that is merged into the Application.Resources) it can override the default style of the control. For mostly lookless controls like the stackpanel it isn't a problem, but for textboxes etc you may stumble upon this problem, which luckily has some workarounds.

提交回复
热议问题