#808 – How Shape Elements Are Positioned within a Canvas
April 29, 2013 2 Comments
The different Shape elements (e.g. Ellipse, Line, Path, Polygon, Polyline or Rectangle) describe a shape to be drawn using an X,Y coordinate system, with X increasing from left to right and Y increasing from top to bottom.
When you add Shape elements to a Canvas, the coordinates specified for the elements are used to determine the element’s position within the coordinate space of the Canvas. For example, a point in a shape at (0,0) would be located in the upper left corner of the Canvas.
<Canvas Margin="10" Background="AliceBlue"> <Polygon Points="10,10 60,60 60,100 140,80 120,40" Stroke="DarkViolet" StrokeThickness="2"/> </Canvas>
If you set any of attached properties for positioning with the Canvas (Left, Top, Right, Bottom), these properties will be used to offset the entire shape, relative to one (or more) of the sides of the canvas.
<Canvas Margin="10" Background="AliceBlue"> <Polygon Canvas.Left="50" Canvas.Bottom="0" Points="10,10 60,60 60,100 140,80 120,40" Stroke="DarkViolet" StrokeThickness="2"/> </Canvas>
Pingback: Dew Drop – April 29, 2013 (#1,536) | Alvin Ashcraft's Morning Dew
Pingback: Interesting .NET Links - April 29 , 2013 | TechBlog