I’m trying to resize an image on a UWP Image control (XAML) using
ScaleTransform t = (ScaleTransform)image.RenderTransform;
But am getting an error:
Unable to cast object of type 'Windows.UI.Xaml.Media.MatrixTransform' to type 'Windows.UI.Xaml.Media.ScaleTransform'.
So how do I resize it (not using the Stretch
property)?
Assign a new ScaleTransform to the RenderTransform
property once:
image.RenderTransform = new ScaleTransform();
Now you can later safely access it by
var t = (ScaleTransform)image.RenderTransform