CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 1999
    Location
    Fort Worth Texas
    Posts
    614

    Question Popup and Right click menu

    I am trying to create a menu that appears when right clicking but am not sure how to implement it in WPF and have not found any online info about it. Anyone have a how to link about this? Thank you
    Last edited by Jim Bassett; November 30th, 2009 at 12:12 AM. Reason: Needed to add reference to WPF

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Popup and Right click menu

    Most every control has a ContextMenu collection. All you need to do is add your menu items to it.

    Here's an example of adding a context menu to a grid control:

    Code:
    <Grid>
      <Grid.ContextMenu>
        <ContextMenu>
          <MenuItem Command="{x:Static uc:AppCommands.EditShift}" />
          <Separator />
          <MenuItem Command="{x:Static uc:AppCommands.AddShift}" />
          <MenuItem Command="{x:Static uc:AppCommands.DeleteShift}" />
          <Separator />
          <MenuItem Command="{x:Static uc:AppCommands.MoveUpShift}" />
          <MenuItem Command="{x:Static uc:AppCommands.MoveDownShift}" />
          <Separator />
          <MenuItem Command="{x:Static uc:AppCommands.ClearShiftEmployee}" />
          <Separator />
          <MenuItem Command="{x:Static uc:AppCommands.SaveTemplate}" />
        </ContextMenu>
      </Grid.ContextMenu>
     
      <!-- other grid code -->
     
    </Grid>


  3. #3
    Join Date
    May 1999
    Location
    Fort Worth Texas
    Posts
    614

    Exclamation Re: Popup and Right click menu

    Thank you Arjay

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured