Reputation: 69
I have created a path object in the code behind and scaling it. PFB the code.
path.Stroke = Brushes.Black;
path.Stroke = Brushes.Black;
path.StrokeThickness = 1;`
path.Data.Transform = new ScaleTransform(0.5,0.5);
How to do the same in XAML?
Upvotes: 3
Views: 1693
Reputation: 1660
Updated
You can write something like this.
<Window.Resources>
<ScaleTransform ScaleX="0.5" ScaleY="0.5" x:Key="testTransform" />
</Window.Resources>
<Path Stroke="Black" StrokeThickness="1">
<Path.Data>
<PathGeometry Transform="{StaticResource testTransform}">
<PathFigure StartPoint="10,50">
<LineSegment Point="200,70" />
</PathFigure>
</PathGeometry>
</Path.Data>
</Path>
Upvotes: 2
Reputation: 128062
Setting the Transform
property of the Geometry in a Path's Data
in XAML would look like shown below. In contrast to the Path's RenderTransform
, the Geometry.Transform
property only transform the geometry, but not any visual aspects like e.g. the StrokeThickness.
<Path Stroke="Black" StrokeThickness="1">
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
M 0,10 L10,0 20,10 10,20Z
</PathGeometry.Figures>
<PathGeometry.Transform>
<ScaleTransform ScaleX="0.5" ScaleY="0.5"/>
</PathGeometry.Transform>
</PathGeometry>
</Path.Data>
</Path>
Upvotes: 3