Click here to Skip to main content
15,867,594 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
I have use the given below code to display the image on canvas and now I want to delete the displayed image on the long press on that image. I try the contextmenu for that but it not works. please anybody tell me how i can do it or properly used contextmenu for it


C#
private void Stickers1_SelectionChanged(object sender, SelectionChangedEventArgs e) {
    var selecteditem = e.AddedItems[0] as StickersImageListModel; 

    Stickers1.Visibility = Visibility.Collapsed;    

    // taking image from a list StickersImageListModel of images and bind with imageitem varaible    
    Image imageitem = new Image();    
    BitmapImage image = new BitmapImage(new System.Uri(selecteditem.Imageurl, UriKind.Absolute));    
    imageitem.Source = image;

    //Add the images on canvas    
    my_canvas.Children.Add(imageitem);    
    imageitem.AllowDrop = true;

    // DRag and drop the images on canvas   
    imageitem.ManipulationMode = ManipulationModes.All;    
    imageitem.ManipulationDelta += Drag_ManipulationDelta;    
    CompositeTransform ct = new CompositeTransform();    
    imageitem.RenderTransform = ct;   

    my_canvas.Visibility = Visibility.Visible;    
}


What I have tried:

i have tried the contextmenu but it would not work or may be I used it wrongly.
so please tell me for this what i should use and how.
Posted
Comments
Sergey Alexandrovich Kryukov 13-Jun-16 13:59pm    
What does it mean, "longpress", exactly? If this is keeping the mouse button pressed for some predefined period of time, what's the problem? Just measure the time between events and then do you action or not, depending on duration. But I would not advise doing so. How are you going to explain such behavior to the user? Will be there any keyboard analog of the same action?
—SA
vikas sharawat 14-Jun-16 0:26am    
dear sir I have develop an application for the tab so in touch screen i want that when i press or touch any image on my canvas for a long time without moving that image it shows or display a context menu type in which i found a delete option and i able to delete that particular image

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900