1
votes

I have an issue with regards to using a ScaleTransform on a Canvas in Silverlight, the Canvas scales correctly, however the Height and Width values always remain the same.
e.g. a 100x100 Canvas scaled so it appears 200x200 is still 100x100 with regards to the Height and Width values, how can these be updated to reflect the new size.

Another related issue is how to alter the Height and Width of an element and have this Scale the Canvas or XAML element appropriately ie. setting a 100x100 element to 200x200 makes everything in it twice as big - this should be a solution where only the height and width of the element are set to alter the scale.

These questions are related to the same issue - hopefully there is a solution, that works in Silverlight 3.0


Height and Width need updated so that when this Canvas is in a ScrollViewer the Scrollbar correctly updates for the new size - this happens if the height and width is assigned manually to the new scaled size but this needs to work for all sizes.
Conversly I need to have another canvas that when its Height and Width is changed the elements inside are scaled appropriately as this will be a resizable icon for use on the same or another Canvas.


If this is not possible in Silverlight directly is there anyway of achieving this effect in code, if not in XAML, as this is possible in WPF if an ImageBrush is used, however Silverlight does not support this and need a scalable canvas, and a canvas that when scaled updates it's own height and width.

1

1 Answers

2
votes

A UIElement is unaware of any transform applied to it. So it's not possible for its width and height properties to reflect the transform.


Well one option is to not use a transform at all but to use a ViewBox (from the silverlight toolkit)

The viewbox scales it content to always fill the viewbox.