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 7076131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:15:41+00:00 2026-05-28T06:15:41+00:00

I am currently making a context menu which open from left button click instead

  • 0

I am currently making a context menu which open from left button click instead of right button click and to do that I inhibit the right click by handling the ContextMenuOpening event like this

private void PinBorder_ContextMenuOpening(object sender, System.Windows.Controls.ContextMenuEventArgs e)
{
    e.Handled = true;
}

and I open the context menu by myself on reaction to the MouseButtonLeftDown event like this :

private void PinBorder_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
    PinBorder.ContextMenu.PlacementTarget = PinBorder;
    PinBorder.ContextMenu.Placement = System.Windows.Controls.Primitives.PlacementMode.Center;
    PinBorder.ContextMenu.HorizontalOffset = 0;
    PinBorder.ContextMenu.VerticalOffset = 0;
    PinBorder.ContextMenu.IsOpen = true;
    e.Handled = true;
}

the problem here is when the ContextMenu is opened the first time everything goes well but if I add an item to the observable collection bound to the context menu and try to reopen it, the context menu is clipped to its previous size (if I try to move the context menu selection with up/down key I can guess that an entry has been created but I can’t see it because it is clipped).

I tried to remove the click inhibition stuffs and every thing goes well in that case.

I read about such an issue in .net framework 3.5 but i am targeting 4.0.

Does anyone has a solution ?

  • 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-28T06:15:42+00:00Added an answer on May 28, 2026 at 6:15 am

    If finally found a workaround to get what I want even if this solution must allocate more memory than necessary.

    I recreate the whole contextmenu each time the context menu must open.

    private void PinBorder_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
    {
        PropertyInputPin.UpdateCompatibleAdjusters();
    
        PinBorder.ContextMenu = new System.Windows.Controls.ContextMenu();
    
        Binding binding = new Binding("CompatibleAdjusters");
        binding.Mode = BindingMode.OneWay;
        binding.Source = DataContext;
        BindingOperations.SetBinding(PinBorder.ContextMenu, ContextMenu.ItemsSourceProperty, binding);
    
        PinBorder.ContextMenu.PlacementTarget = PinBorder;
        PinBorder.ContextMenu.Placement = System.Windows.Controls.Primitives.PlacementMode.Center;
        PinBorder.ContextMenu.HorizontalOffset = 0;
        PinBorder.ContextMenu.VerticalOffset = 0;
        PinBorder.ContextMenu.IsOpen = true;
    
        for (int i = 0; i < PropertyInputPin.CompatibleAdjusters.Count; i++)
        {
            MenuItem mi = PinBorder.ContextMenu.ItemContainerGenerator.ContainerFromIndex(i) as MenuItem;
            mi.Click += ContextMenu_Click;
        }
    
        e.Handled = false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently making some system that will gather statistical reports from different sites, for
I'm currently making an iPhone app that has PDF viewing a crucial part of
currently im making some crawler script, one of problem is sometimes if i open
I'm trying to make a context menu for a control that is linked to
Here is my code currently. I'm making a java program that seaches Active Directory
i'm currently making search engine for a website content (only for searching within that
I am currently making a website that returns quite a few xml types and
I'm currently making an iphone web app based on Google App Engine (python). I
I'm currently making a front end to display license information for my companies software
I'm currently making a GWT project where I display some HTML in a RichTextArea

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.