2010-04-15 70 views
2

我想增加20的圖像大小。所以我使用ScaleTransform如下所示..但下面的代碼不會做任何規模的Tranform ..任何幫助將不勝感激...ScaleTransform圖像

<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" 
      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> 

回答

6

您是否嘗試過在圖片上設置<RenderTransform>?事情是這樣的:

<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> 

這會初始化RenderTransform,這樣你可以參考從其他地方給它。我不得不使用Silverlight來做到這一點。

相關問題