Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5997527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:16:35+00:00 2026-05-23T00:16:35+00:00

Goal: Display different context menu if right clicking a row from the listview or

  • 0

Goal:
Display different context menu if right clicking a row from the listview or right clicking inside of listview without making a selection of a row.

Problem:
Having difficult to find a solution that enable to display different context menu once clicking on something.


private void lstvdMonth_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
{



    ContextMenu myContextMenu = new ContextMenu();;

    if (MouseButtonState.Released == e.RightButton)
    {


        MenuItem menuItem3 = new MenuItem();
        menuItem3.Header = "Add quantity";
        myContextMenu.Items.Add(menuItem3);
        menuItem3.Click += new RoutedEventHandler(menuItem3_Click);

        MenuItem menuItem2 = new MenuItem();
        menuItem2.Header = "Delete";
        myContextMenu.Items.Add(menuItem2);
        menuItem2.Click += new RoutedEventHandler(menuItem2_Click);
    }
    else
    {
        MenuItem menuItem1 = new MenuItem();
        menuItem1.Header = "New product";
        myContextMenu.Items.Add(menuItem1);
        menuItem1.Click += new RoutedEventHandler(menuItem1_Click);
    }

    myContextMenu.IsOpen = true;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:16:36+00:00Added an answer on May 23, 2026 at 12:16 am

    I think what you should test in the if is whether any items are selected in the ListView (e.g. SelectedItem == null).

    How exactly do you expect the mouse button to ever be down in the MouseUp event?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Goal: Display the result without using any line between column and row Problem: I
My goal is to display two <div> s side-by-side with the content from both
My goal is to display the same icon twice, but each time in different
My goal is to add different Controls/UserControls in a WPF ListView. The Controls can
Original goal: I have a TreeMenu that i use to display my Menu. In
Goal: Display a custom location list on google maps based on the location of
On a Drupal app, my goal is to display a page with a couple
GOAL: I'm making a UDP socket to send and receive data. I am testing
My goal is to generate an array having multiple jsons in which different keys
I need to execute/display a series of events from a Arraylist to a JTextArea,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.