我使用以下代码在画布上显示图像
void Stickers1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var selecteditem = e.AddedItems[0] as StickersImageListModel;
{
Stickers1.Visibility = Visibility.Collapsed;
Image imageitem = new Image();
BitmapImage image = new BitmapImage(new System.Uri(selecteditem.Imageurl, UriKind.Absolute));
imageitem.Source = image;
my_canvas.Children.Add(imageitem);
imageitem.AllowDrop = true;
}
my_canvas.Visibility = Visibility.Visible;
}
现在我想将这些图像拖放到我的画布上,请帮助我这样做,我试过这个
private Image _imageUrl;
public Image Imageurl
{
get { return _imageUrl; }
set { _imageUrl = value; }
}
private void my_canvas_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
if ((e.Position.X > Canvas.GetLeft(Imageurl) && e.Position.X < Canvas.GetLeft(Imageurl) + Imageurl.Width)
|| (e.Position.Y > Canvas.GetTop(Imageurl) && e.Position.Y < Canvas.GetTop(Imageurl) + Imageurl.Height))
{
{
Canvas.SetLeft(Imageurl, e.Position.X);
Canvas.SetTop(Imageurl, e.Position.Y);
}
}
}