#1,144 – Geometry in Custom Shape Doesn’t Automatically Scale
August 26, 2014 1 Comment
If you define a custom Shape by creating some Geometry, the resulting geometry will not automatically scale when shape’s size is changed.
Suppose that we have the following custom shape.
public class MyShape : Shape { protected override Geometry DefiningGeometry { get { StreamGeometry geom = new StreamGeometry(); using (StreamGeometryContext ctx = geom.Open()) { ctx.BeginFigure( new Point(0.0, 0.0), false, false); ctx.LineTo( new Point(50.0, 50.0), true, false); } return geom; } } }
Placing this control in a StackPanel, it’s size is just large enough to accommodate the geometry.
If we explicitly make the shape larger, the underlying geometry stays the same size.
Pingback: Dew Drop – August 26, 2014 (#1842) | Morning Dew