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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:35:38+00:00 2026-05-12T09:35:38+00:00

In my app, I’d like to make the context menu of a button appear

  • 0

In my app, I’d like to make the context menu of a button appear when the user left clicks on the button. I can do this by creating an event handler for button’s click event and then setting it’s context menu’s IsOpen property to true, but I’m wondering if there’s a pure xaml solution to do the same thing. Any ideas?

Thanks!

  • 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-12T09:35:39+00:00Added an answer on May 12, 2026 at 9:35 am

    You can create a new template for the button and then provide a context menu in the template’s visual tree. Something like this:

    <Style TargetType="{x:Type Button}">
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="{x:Type Button}">
            <Border>
              <ContentPresenter HorizontalAlignment="Center"
                                VerticalAlignment="Center"/>
              <Border.ContextMenu>
                <ContextMenu Name="contextMenu">
                  <MenuItem Header="Here's a menu."/>
                </ContextMenu>
              </Border.ContextMenu>
            </Border>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>
    

    You could then trigger using the IsPressed property of the button and hook it up using a setter with contextMenu as the TargetName.

    My real question is, what are you using this for? Opening a context-menu on left-click is going to be inherently flawed, because context-menus, by their nature, close when any other element is clicked. Which means this trigger, even when properly set up, will simply open and close the context menu immediately. I am curious as to why you need this kind of behavior; perhaps there is a better way of doing it than using a context-menu.

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

Sidebar

Related Questions

app link: http://itunes.apple.com/en/app/quick-tweet/id505987287?mt=12 How can i make something like that circle? is that a
App having screen1, screen2, screen3 , screen4 user can go to screen3 from remaining
My app only allows access if the current user is a specific type, this
App A has this BroadcastReceiver in its manifest (within <application>): And this receiver: public
my app has a submit feedback form. Is there a way to can capture
My app is placing a button with a custom background image and i doesn't
IPhone app, ios 4+. Creating an app with 50+ pages of info and I
App Description: I have a UIWebview and a Toolbar beneath it. A button on
My app uses LoadLibrary to load plugins at run-time and users can accidentally try
App is in prism/mvvm/mef and uses loading by attribute like StockTraderRI. My shell window

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.