c# - I want to delete an image on longpress on the image in canvas -
i have use given below code display image on canvas , want delete displayed image on long press on image. try contextmenu not works. please tell me how can or used contextmenu it
private void stickers1_selectionchanged(object sender, selectionchangedeventargs e) { var selecteditem = e.addeditems[0] stickersimagelistmodel; stickers1.visibility = visibility.collapsed; // taking image list stickersimagelistmodel of images , bind imageitem varaible image imageitem = new image(); bitmapimage image = new bitmapimage(new system.uri(selecteditem.imageurl, urikind.absolute)); imageitem.source = image; //add images on canvas my_canvas.children.add(imageitem); imageitem.allowdrop = true; // drag , drop images on canvas imageitem.manipulationmode = manipulationmodes.all; imageitem.manipulationdelta += drag_manipulationdelta; compositetransform ct = new compositetransform(); imageitem.rendertransform = ct; my_canvas.visibility = visibility.visible; }
you can use holding
event image. have note holding event wont fired desktop apps instead have use righttapped
event. if targetting mobile apps can use holding event
// imageitem.righttapped += imageitem_righttapped; imageitem.holding += imageitem_holding; imageitem.isrighttapenabled = true; imageitem.isholdingenabled = true; private void imageitem_righttapped(object sender, righttappedroutedeventargs e) { mycanvas.children.remove(sender image); } private void imageitem_holding(object sender, holdingroutedeventargs e) { mycanvas.children.remove(sender image); }
Comments
Post a Comment