Hi. I am trying to perform a TranslateTransform on an Image using this code:
double to;
int increment = 2;
TranslateTransform tt = new TranslateTransform();
background.RenderTransform = tt;
to = Canvas.GetTop(background) + increment;
DoubleAnimation da = new DoubleAnimation(to, TimeSpan.FromSeconds(0));
Canvas.SetTop(background, to);
tt.BeginAnimation(TranslateTransform.YProperty, da);
This works when the Image exists in a Window:
<Window x:Class="trpgwpf1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" ResizeMode="CanMinimize" KeyDown="WindowKeyDown">
<Canvas Name="canvas">
<Image Name="background" Stretch="UniformToFill" Source="Images\test.png" />
</Canvas>
</Window>
But nothing happens when I try to transform an Image on a Page:
<Page x:Class="trpgwpf1.Page1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Page1">
<Canvas Name="canvas">
<Image Name="background" Stretch="UniformToFill" Source="Images\test.png" />
</Canvas>
</Page>
Does anyone know why? I can't find a reference to anything like this anywhere.