Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. context menu

context menu

Scheduled Pinned Locked Moved WPF
questioncsswpf
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    michaelgr1
    wrote on last edited by
    #1

    Hello, I have a button and a context menu on it. I want to align the context menu to be opened on top of the button. I mean on the Upper Left corner of the button. How can i do it in XAML? currently i use the code:

    Button Grid.Column="1" BorderThickness="0" Name="dropDownbtn" Click="dropDownbtn_Click" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">

            <Button.ContextMenu>
                
            </Button.ContextMenu>
        </Button>
    
    P 1 Reply Last reply
    0
    • M michaelgr1

      Hello, I have a button and a context menu on it. I want to align the context menu to be opened on top of the button. I mean on the Upper Left corner of the button. How can i do it in XAML? currently i use the code:

      Button Grid.Column="1" BorderThickness="0" Name="dropDownbtn" Click="dropDownbtn_Click" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">

              <Button.ContextMenu>
                  
              </Button.ContextMenu>
          </Button>
      
      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      The easiest way to do this is to use the ContextMenuService on the button itself. So, in your button definition, add ContextMenuService.Placement="Top"

      *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

      "Mind bleach! Send me mind bleach!" - Nagy Vilmos

      My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

      M 1 Reply Last reply
      0
      • P Pete OHanlon

        The easiest way to do this is to use the ContextMenuService on the button itself. So, in your button definition, add ContextMenuService.Placement="Top"

        *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

        "Mind bleach! Send me mind bleach!" - Nagy Vilmos

        My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

        M Offline
        M Offline
        michaelgr1
        wrote on last edited by
        #3

        OK. Another issue is that this context menu opened on left mouse click on button. But it never enters the can_execute . But when i click Right Mouse Button it does enters can_execute. How to solve it?

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups