开发者

ScaleTransform for Image

开发者 https://www.devze.com 2022-12-27 05:22 出处:网络
I am trying to increase the size of the image by 20. So I am using ScaleTransform as shown below.. but the following code doesn\'t do any scale Tranform.. Any help would be appreciated...

I am trying to increase the size of the image by 20. So I am using ScaleTransform as shown below.. but the following code doesn't do any scale Tranform.. Any help would be appreciated...

<Grid>
    <Canvas>
    <Canvas Height="50" Width="50" Canvas.Top="10" Canvas.Left="100"
            Visibility="Visible">
        <Image Name="Img" Source="Help.PNG" Canvas.Left="0" Canvas.Top="0">
        </Image>
    </Canvas>
    <Button Canvas.Left="100" Canvas.Top="100" Height="42.5" Name="button3开发者_JAVA百科"
            Width="100" Visibility="Visible">
        <Button.Triggers>
            <EventTrigger RoutedEvent="Button.Click">
                <BeginStoryboard>
                    <Storyboard Name="MoveBox">
                        <DoubleAnimation Storyboard.TargetName="Img"
      Storyboard.TargetProperty="(Image.RenderTransform).(ScaleTransform.ScaleX)"
      From="1" To="20" BeginTime="0:0:3.75" Duration="0:0:1.25" />
                        <DoubleAnimation Storyboard.TargetName="Img"
      Storyboard.TargetProperty="(Image.RenderTransform).(ScaleTransform.ScaleY)"
      From="1" To="20" BeginTime="0:0:3.75" Duration="0:0:1.25" />
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
        </Button.Triggers>
    </Button>
    </Canvas>
</Grid>


Have you tried setting a <RenderTransform> on the image? Something like this:

    <Image Name="Img" Source="Help.PNG" Canvas.Left="0" Canvas.Top="0">
        <Image.RenderTransform>
            <ScaleTransform x:Name="scale" ScaleX="1" ScaleY="1"
                            CenterX="0.5" CenterY="0.5" />
        </Image.RenderTransform>
    </Image>

This initialises the RenderTransform so that you can refer to it from elsewhere.

I've had to do this with Silverlight.

0

精彩评论

暂无评论...
验证码 换一张
取 消