I have a group of elements inside a grid and want to align them along the
left side of the grid. I also want have this group centered vertically and
the xaml below demonstrates the appearance want to achieve. At runtime I
don't know how many there will be, but there will always be at least 1 which
should be in the exact center of the left side, and I will dynamically and
remove elements to the left side. These elements have a height of "12" so
logic tells me if I want to add another element placed right on top of the
previous one, I should set the new element's top margin to "-12" more than
the previous element's top margin. However, this isn't the case. I need to
work with units of 24 (or rather double the element's height).
This is confusing to me. Can someone please explain why when I have an
element with a height of "12" and I want to move it a distance of "12" up or
down, I need to work with a top margin in units of "24" or double it's
height?
Thanks.
<Window x:Class="Diagra mTools.Window3"
xmlns="http://schemas.microso ft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microso ft.com/winfx/2006/xaml"
Title="Window3" Height="300" Width="300">
<!--MARGIN : Left, Top, Right, Bottom -->
<Grid>
<!-- LEFT SIDE PANEL-->
<Grid Margin="40,40,4 0,40" Background="Cor nsilk" Name="myControl " >
<Grid HorizontalAlign ment="Left" Width="20"
Margin="-10,10,0,10" Background="Lig htBlue" Name="LeftConne ctorPanel">
<Rectangle Height="12" Width="20" Margin="-10,-72,0,0"
Name="rectangle 6" HorizontalAlign ment="Left" Stroke="Black" Fill="Purple"
/>
<Rectangle Height="12" Width="20" Margin="-10,-48,0,0"
Name="rectangle 4" HorizontalAlign ment="Left" Stroke="Black" Fill="Green" />
<Rectangle Height="12" Width="20" Margin="-10,-24,0,0"
Name="rectangle 2" HorizontalAlign ment="Left" Stroke="Black" Fill="Blue" />
<Rectangle Height="12" Width="20" Margin="-10,0,0,0"
Name="rectangle 1" HorizontalAlign ment="Left" Stroke="Black" Fill="Red" />
<Rectangle Height="12" Width="20" Margin="-10,24,0,0"
Name="rectangle 3" HorizontalAlign ment="Left" Stroke="Black" Fill="Blue"
/>
<Rectangle Height="12" Width="20" Margin="-10,48,0,0"
Name="rectangle 5" HorizontalAlign ment="Left" Stroke="Black" Fill="Green"
/>
</Grid>
<!-- RIGHT SIDE PANEL-->
<Grid HorizontalAlign ment="Right" Width="20" Margin="0,10,-10,
10" Background="Lig htBlue" Name="RightConn ectorPanel">
<!--<Rectangle Height="12" Width="20" Margin="0,-48,-10,0"
Name="rectangle 4a" HorizontalAlign ment="Right" Stroke="Black" Fill="Green"
/>-->
<Rectangle Height="12" Width="20" Margin="0,-12,-10,0"
Name="rectangle 2a" HorizontalAlign ment="Right" Stroke="Black" Fill="Blue"
/>
<Rectangle Height="12" Width="20" Margin="0,12,-10,0"
Name="rectangle 1a" HorizontalAlign ment="Right" Stroke="Black" Fill="Red"
/>
<!--<Rectangle Height="12" Width="20" Margin="0,24,-10,0"
Name="rectangle 3a" HorizontalAlign ment="Right" Stroke="Black" Fill="Blue"
/>
<Rectangle Height="12" Width="20" Margin="0,48,-10,0"
Name="rectangle 5a" HorizontalAlign ment="Right" Stroke="Black" Fill="Green"
/>-->
</Grid>
<!-- TOP SIDE PANEL-->
<Grid VerticalAlignme nt="Top" Height="20" Margin="10,-10,10,
0" Background="Lig htBlue" Name="TopConnec torPanel">
<Rectangle Height="20" Width="12" Margin="0,-10,48,0"
Name="rectangle 4b" VerticalAlignme nt="Top" Stroke="Black" Fill="Green" />
<Rectangle Height="20" Width="12" Margin="0,-10,24,0"
Name="rectangle 2b" VerticalAlignme nt="Top" Stroke="Black" Fill="Blue" />
<Rectangle Height="20" Width="12" Margin="0,-10,0,0"
Name="rectangle 1b" VerticalAlignme nt="Top" Stroke="Black" Fill="Red" />
<Rectangle Height="20" Width="12" Margin="0,-10,-24,0"
Name="rectangle 3b" VerticalAlignme nt="Top" Stroke="Black" Fill="Blue" />
<Rectangle Height="20" Width="12" Margin="0,-10,-48,0"
Name="rectangle 5b" VerticalAlignme nt="Top" Stroke="Black" Fill="Green" />
</Grid>
<!-- BOTTOM SIDE PANEL-->
<Grid VerticalAlignme nt="Bottom" Height="20"
Margin="10,-10,10, 0" Background="Lig htBlue" Name="Bottom">
<Rectangle Height="20" Width="12" Margin="0,-10,48,0"
Name="rectangle 4c" VerticalAlignme nt="Bottom" Stroke="Black" Fill="Green"
/>
<Rectangle Height="20" Width="12" Margin="0,-10,24,0"
Name="rectangle 2c" VerticalAlignme nt="Bottom" Stroke="Black" Fill="Blue" />
<Rectangle Height="20" Width="12" Margin="0,-10,0,0"
Name="rectangle 1c" VerticalAlignme nt="Bottom" Stroke="Black" Fill="Red" />
<Rectangle Height="20" Width="12" Margin="0,-10,-24,0"
Name="rectangle 3c" VerticalAlignme nt="Bottom" Stroke="Black" Fill="Blue"
/>
<Rectangle Height="20" Width="12" Margin="0,-10,-48,0"
Name="rectangle 5c" VerticalAlignme nt="Bottom" Stroke="Black" Fill="Green"
/>
</Grid>
</Grid>
</Grid>
</Window>
--
mo*******@newsg roup.nospam