Skip to main content
Home Forums Silverlight Programming Report a Silverlight Bug Transform of PathGeometry defined by Mini-Language doesn't do anything
1 replies. Latest Post by shacktoms on June 29, 2009.
(0)
shacktoms
Member
185 points
149 Posts
06-08-2009 12:13 PM |
In XAML, I can define a <Path> element with the Data specified by the mini language. In that case, the Geometry is created as a PathGeometry. This PathGeometry has a Transform property, but setting that property does not transform the geometry.
If this bug were fixed, it would be very convenient for rescaling the coordinates of graphs that were created with the mini-language, without rescaling the StrokeThickness that is specified in the Path (as happens with a RenderTransform). Supposedly, Geometries created with the mini-language outperform geometries created with explicit Figures, so it would be nice to be able to avoid creating the Figures.
06-29-2009 2:38 PM |
As a workaround, a Geometry transform is implied by Width and Height if Stretch is set to Fill, Uniform, or UniformToFill.
The only small caveat is that you have to first add the StrokeThickness to the Width and Height, and then subtract half the StrokeThickness from the Margin in order to make things come out as you would likely expect.
That is, if your geometry draws a 100x100 square, and your StrokeThickness is 10, then in order to scale your geometry by 0.5 you set Stretch="Fill" (or "Uniform" or "UniformToFill") and then you might think you would just set Width="50" and Height="50" but you will really need to set Width="60", Height="60" and Margin="-5". A little bizarre, but it works.
In any case, the fact that this works shows that somewhere inside the implemtation, a PathGeometry created by the mini language can be transformed after the fact, it is just that doing it by setting the Transform property is broken.