I want to draw a user control with content displayed. Essentially I want a custom box around whatever the content is.
I want that box to scale, so I am using a viewbox. Unfortunately, the viewbox transforms the entire displayed control, not just the geometry of the box. This leads to the lines used for the border to be stretched.
Here is my control that I need to stretch the points in the vector path to fit the parent box.
Here is the undesirable result that I get.
Is there any good way to strech-to-fill the geometry while not scaling the line drawing thickness?
I realize I could to this a few other ways with such simple geometry, but in my actual application the path is much more complicated.
Here is my control code for those who are interested :
<UserControl.Template>
<ControlTemplate TargetType="{x:Type UserControl}">
<Grid>
<Viewbox Stretch="Fill">
<Canvas Name="svg2" Margin="0" Width="100" Height="63" >
<Path Fill="#FFFFFFFF" Stroke="#FF6800FF" StrokeThickness="4" StrokeStartLineCap="Flat" StrokeEndLineCap="Flat" StrokeLineJoin="Miter" StrokeMiterLimit="4" Name="rect2985" RenderTransformOrigin="0,0">
<Path.Data>
<PathGeometry FillRule="Nonzero" Figures="M 0,250 L 0,50 L 150,50 L 200,-0.96 L 250,50 L 400,50 L 400,250 L 0,250z">
<PathGeometry.Transform>
<TransformGroup>
<ScaleTransform ScaleX=".24" ScaleY=".23" />
</TransformGroup>
</PathGeometry.Transform>
</PathGeometry>
</Path.Data>
<Path.RenderTransform>
<TransformGroup>
<TranslateTransform X="2.1" Y="3" />
</TransformGroup>
</Path.RenderTransform>
</Path>
<Grid Canvas.Top="17" Width="90" HorizontalAlignment="Center" Height="40" Canvas.Left="5">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Grid>
</Canvas>
</Viewbox>
</Grid>
</ControlTemplate>
</UserControl.Template>