WPF TranslateTransform的使用
1、水平移动
2、单击后向X,Y移动15
<Canvas x:Class= "ControlTest2.TranslateTransformDemon.TranslateTransformInCanvas"
xmlns= "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x= "http://schemas.microsoft.com/winfx/2006/xaml"
Height= "300" Width= "300" >
<Rectangle MouseLeftButtonDown= "Rectangle_MouseLeftButtonDown"
Width= "50" Height= "50"
Fill= "RoyalBlue" >
<Rectangle.RenderTransform>
<TranslateTransform x:Name= "myTranslateTransform" />
</Rectangle.RenderTransform>
</Rectangle>
</Canvas> |
Code:
private void Rectangle_MouseLeftButtonDown( object sender, MouseButtonEventArgs e)
{ // Increase the X and Y properties.
myTranslateTransform.X = myTranslateTransform.X + 15;
myTranslateTransform.Y = myTranslateTransform.Y + 15;
} |
本文转自Work Hard Work Smart博客园博客,原文链接:http://www.cnblogs.com/linlf03/archive/2011/11/23/2260268.html,如需转载请自行联系原作者