Margin property described by MSDN, quote :"The http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.margin.aspx property describes the distance between an element and its child (why not parent? ) or peers." But how to decide if the Margin describes the distance between an element and its child(parent) or peers? here are two examples:
first one:
<GroupBox Header="Experience" Height="200" Name="yearsExperience" Width="200">
<StackPanel Margin="0,0,0,0" >
<RadioButton Content="Up to 1 year" Height="16" Name="novice" Width="120" Margin="0, 10, 0, 0" />
<RadioButton Content="1 to 4 years" Height="16" Name="intermediate" Width="120" Margin="0, 20, 0, 0" />
<RadioButton Content="5 to 9 years" Height="16" Name="experienced" Width="120" Margin="0, 20, 0, 0" />
<RadioButton Content="10 or more" Height="16" Name="accomplished" Width="120" Margin="0, 20, 0, 0" />
</StackPanel>
</GroupBox>
second one:
<GroupBox Header="Experience" Height="200" Name="yearsExperience" Width="200">
<Grid Margin="0,0,0,0" >
<RadioButton Content="Up to 1 year" Height="16" Name="novice" Width="120" Margin="0, 10, 0, 0" />
<RadioButton Content="1 to 4 years" Height="16" Name="intermediate" Width="120" Margin="0, 20, 0, 0" />
<RadioButton Content="5 to 9 years" Height="16" Name="experienced" Width="120" Margin="0, 20, 0, 0" />
<RadioButton Content="10 or more" Height="16" Name="accomplished" Width="120" Margin="0, 20, 0, 0" />
</Grid>
</GroupBox>
Apparently in the first example , the margin describes the distance between peers(RadioButtons), while in the second example ,the margin describles the distance between RadioButtons and Grid (parent) top, and RadioButtons shall overlap each other . that's really tricky, so what's really going on?