WP7 实现变形特效
XAML:
<Canvas x:Name="LayoutRoot" Background="White">
<Image x:Name="img" Stretch="None" Source="../images/jiqiren2.jpg"
Canvas.Left="177" Canvas.Top="0"></Image>
<Button FontSize="18" Content="旋转对象" Canvas.Left="278"
Canvas.Top="142" Click="Button_Click" />
</Canvas>
<Image x:Name="img" Stretch="None" Source="../images/jiqiren2.jpg"
Canvas.Left="177" Canvas.Top="0"></Image>
<Button FontSize="18" Content="旋转对象" Canvas.Left="278"
Canvas.Top="142" Click="Button_Click" />
</Canvas>
后台:
public partial class RenderTransformWithCSharp : UserControl
{
private int angle = 0;//声明旋转角度变量
//声明旋转对象
private RotateTransform rotate = new RotateTransform();
public RenderTransformWithCSharp()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
//每次点击增加45度
angle += 45;
//指定旋转对象的角度
rotate.Angle = angle;
//设置旋转角度中心点
rotate.CenterX = 100;
rotate.CenterY = 100;
//将旋转对象赋给UI变形对象
img.RenderTransform = rotate;
}
}
{
private int angle = 0;//声明旋转角度变量
//声明旋转对象
private RotateTransform rotate = new RotateTransform();
public RenderTransformWithCSharp()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
//每次点击增加45度
angle += 45;
//指定旋转对象的角度
rotate.Angle = angle;
//设置旋转角度中心点
rotate.CenterX = 100;
rotate.CenterY = 100;
//将旋转对象赋给UI变形对象
img.RenderTransform = rotate;
}
}