WPF in Expression Blend -add context menu item click-event

Discussion in 'Programming General' started by hampe-92, Nov 16, 2008.

WPF in Expression Blend -add context menu item click-event
  1. Unread #1 - Nov 16, 2008 at 3:21 PM
  2. hampe-92
    Joined:
    Jul 10, 2008
    Posts:
    328
    Referrals:
    0
    Sythe Gold:
    0

    hampe-92 Forum Addict

    WPF in Expression Blend -add context menu item click-event

    In WPF in Blend there is no context menu control as in windows forms... so if I got it right, you have to go to properties for the window and scroll down to "Context menu". There are several of options for the menu but after some searching I found the "Items (Collection)" button...

    then I added all my menu items that I needed, but I can't find how to hook them up to a click-event, (as you can do with regular controls by going to properties and then events)... I just CAN'T find any option like it:confused:

    any ideas??
    thx in advance
     
  3. Unread #2 - Nov 17, 2008 at 12:41 AM
  4. Flaming Idiots
    Joined:
    Dec 22, 2005
    Posts:
    235
    Referrals:
    1
    Sythe Gold:
    0
    Two Factor Authentication User

    Flaming Idiots Active Member
    Visual Basic Programmers

    WPF in Expression Blend -add context menu item click-event

    In the XAML try setting the click handler normally. Just set the Click property to the name of the method that handles the click.

    It should look something like this:

    XAML
    Code:
    <FrameworkElement.ContextMenu>
      <ContextMenu>
        <MenuItem Header="Cut" Click="OnCut" />
        <MenuItem Header="Copy" Click="OnCopy" />
        <MenuItem Header="Paste" Click="OnPaste" />
      </ContextMenu>
    </FrameworkElement.ContextMenu>
     
  5. Unread #3 - Nov 17, 2008 at 9:56 AM
  6. hampe-92
    Joined:
    Jul 10, 2008
    Posts:
    328
    Referrals:
    0
    Sythe Gold:
    0

    hampe-92 Forum Addict

    WPF in Expression Blend -add context menu item click-event

    Ah Thank you very much! :)
    That's a lot easier than that fucked up blend menu :p

    EDIT: one more thing, is it possible to name the context menu items?
    cause I have to chech if one specific menu item is checked or not... thx :)
     
  7. Unread #4 - Nov 17, 2008 at 5:12 PM
  8. Flaming Idiots
    Joined:
    Dec 22, 2005
    Posts:
    235
    Referrals:
    1
    Sythe Gold:
    0
    Two Factor Authentication User

    Flaming Idiots Active Member
    Visual Basic Programmers

    WPF in Expression Blend -add context menu item click-event

    Yeah, just set the Name property of each one.
     
  9. Unread #5 - Nov 18, 2008 at 1:32 PM
  10. hampe-92
    Joined:
    Jul 10, 2008
    Posts:
    328
    Referrals:
    0
    Sythe Gold:
    0

    hampe-92 Forum Addict

    WPF in Expression Blend -add context menu item click-event

    yeah of course... just one problem tho, I can't find any Name property in the menu...:confused:

    EDIT: ah, nvm.. it's just to change it in the xaml.. thx :)
     
< VB6 on Vista (laaag) | Python 2.6 (Saving Scripts) >

Users viewing this thread
1 guest


 
 
Adblock breaks this site