重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
WPF用RenderTransform实现,随便做了个,代码如下。
在郊区等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供网站建设、成都网站设计 网站设计制作按需网站策划,公司网站建设,企业网站建设,成都品牌网站建设,营销型网站,外贸营销网站建设,郊区网站建设费用合理。
XAML
Window x:Class="WpfApplication3.MainWindow"
xmlns="
xmlns:x="
Title="MainWindow"
Height="350"
Width="525"
Grid
Image Name="image" Source="/WpfApplication3;component/Images/Hydrangeas.jpg"
Image.RenderTransform
TransformGroup
RotateTransform x:Name="rt"/
ScaleTransform x:Name="st"/
TranslateTransform x:Name="tt"/
/TransformGroup
/Image.RenderTransform
/Image
StackPanel Orientation="Horizontal"
Height="20"
Button Name="btnScale1"
Content="缩小"
Click="btnScale1_Click" /
Button Name="btnScale2"
Content="放大"
Click="btnScale2_Click" /
Button Name="btnRotation1"
Content="左转"
Click="btnRotation1_Click" /
Button Name="btnRotation2"
Content="右转"
Click="btnRotation2_Click" /
Button Name="btnMove1"
Content="左移"
Click="btnMove1_Click" /
Button Name="btnMove2"
Content="右移"
Click="btnMove2_Click" /
Button Name="btnMove3"
Content="上移"
Click="btnMove3_Click"/
Button Name="btnMove4"
Content="下移"
Click="btnMove4_Click" /
/StackPanel
/Grid
/Window
CS如下
namespace WpfApplication3
{
/// summary
/// MainWindow.xaml 的交互逻辑
/// /summary
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
DataContext = this;
}
private bool _ischecked = false;
public bool IsChecked
{
get
{
return _ischecked;
}
}
private void btnScale1_Click(object sender, RoutedEventArgs e)
{
st.CenterX = image.ActualWidth / 2;
st.CenterY = image.ActualHeight / 2;
st.ScaleX -= 0.1;
st.ScaleY -= 0.1;
}
private void btnScale2_Click(object sender, RoutedEventArgs e)
{
st.CenterX = image.ActualWidth / 2;
st.CenterY = image.ActualHeight / 2;
st.ScaleX += 0.1;
st.ScaleY += 0.1;
}
private void btnRotation1_Click(object sender, RoutedEventArgs e)
{
rt.CenterX = image.ActualWidth / 2;
rt.CenterY = image.ActualHeight / 2;
rt.Angle -= 10;
}
private void btnRotation2_Click(object sender, RoutedEventArgs e)
{
rt.CenterX = image.ActualWidth / 2;
rt.CenterY = image.ActualHeight / 2;
rt.Angle += 10;
}
private void btnMove1_Click(object sender, RoutedEventArgs e)
{
tt.X -= 10;
}
private void btnMove2_Click(object sender, RoutedEventArgs e)
{
tt.X += 10;
}
private void btnMove3_Click(object sender, RoutedEventArgs e)
{
tt.Y -= 10;
}
private void btnMove4_Click(object sender, RoutedEventArgs e)
{
tt.Y += 10;
}
}
}
style
*{ padding:0; margin:0; list-style:none;}
.div{ text-align:center; width:80%; margin:0 auto;}
.div ul{ padding-top:50px;}
.div li{ width:25%; float:left;}
.div img{ border:1px solid red; width:80%; height:80px; margin-bottom:20px;}
.div span{ display:block; margin-top:20px;}
/style
div class="div"
h1标题/h1
ul
liimg name="" src="" /br /图片描述1br /span图片描述2/span/li
liimg name="" src="" /br /图片描述1br /span图片描述2/span/li
liimg name="" src="" /br /图片描述1br /span图片描述2/span/li
liimg name="" src="" /br /图片描述2br /span图片描述2/span/li
/ul
/div
一般来说是因为你的图片路径没写对,或者是图片不存在,请多检查一次。
可以通过css中的position:absolute和relative,并结合z-index调整图片的上下关系
让用户在画板上拖拽、缩放、多图组合操作的话,需要用到Canvas或者SVG的编程,给元素绑定拖拽等鼠标事件