wpf Margin 和 Padding 和边界框的贡献有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25264091/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the diference between Margin and Padding and contribution of the bounding box?
提问by Phill Greggan
Here is image to explain my question better
这是更好地解释我的问题的图像


Every control has bounding box and every control has margins and padding. In the image The Gap between button border and the border of the bounding box is labeled as GAP-B, is this the padding or Margin?
每个控件都有边界框,每个控件都有边距和填充。在图像中按钮边框和边界框边框之间的间隙被标记为 GAP-B,这是填充还是边距?
Also there is gap between the two buttons GAP-A, is this the padding or margin?
两个按钮GAP-A之间也有间隙,这是填充还是边距?
采纳答案by apomene
Gap A is padding where as Gab B is Margin.
间隙 A 是填充,而 Gab B 是边距。
Margin is defined as the gap between the element and each border.
边距定义为元素与每个边框之间的间隙。
Padding is defined as the gap between the border of 2 elements
Padding 定义为 2 个元素的边框之间的间隙
回答by yo chauhan
Gap A is Margin and Gap B is Padding.
间隙 A 是边距,间隙 B 是填充。
Padding on second Border
在第二个边框上填充
<StackPanel>
<Border Height="100" Width="400" >
<Button Content="StackOverFlow" Background="Yellow"/>
</Border>
<Border Padding="20" Background="Lime" Height="100" Width="400">
<Button Content="StackOverFlow" Background="Yellow"/>
</Border>
</StackPanel>


Margin on second border
第二个边界的边距
<StackPanel>
<Border Height="100" Width="400" >
<Button Content="StackOverFlow" Background="Yellow"/>
</Border>
<Border Margin="20" Background="Lime" Height="100" Width="400">
<Button Content="StackOverFlow" Background="Yellow"/>
</Border>
</StackPanel>



