Skip to content

Margin和Padding

L edited this page Dec 30, 2017 · 1 revision

margin是自己与父容器的间距
padding是自己与子控件的间距

<Grid Background="AntiqueWhite">
	<Border Margin="10" Padding="20" Background="CadetBlue">
		<Button Background="BurlyWood"></Button>
	</Border>
</Grid>

效果如图所示 1
Border通过Margin与外部Grid间隔10
Border通过Padding与内部Button间隔20

示例代码

https://github.com/zLulus/NotePractice/tree/dev3/WPF/WpfDemo/MarginAndPadding

Clone this wiki locally