How to associate an event with a menu item in WPF using VS2008?

I participate in the WPF learning process (I don’t know much yet). I know how to associate a menu subtype with an event by directly editing xaml, but I would like to know how to do the same with Visual Studio.

For example, consider the following XAML snippet:

    <Menu DockPanel.Dock ="Top"
          HorizontalAlignment="Left" Background="White" BorderBrush ="Black">
       <MenuItem Header="_File"/>
       <Separator/>
       <MenuItem Header ="_Exit"
                 MouseEnter ="MouseEnterExitArea"
                 MouseLeave ="MouseLeaveArea"
                 Click ="FileExit_Click"/>

I would like to associate the menu item "_Exit" with the corresponding event handlers for MouseEnter, MouseLeave and Click using Visual Studio instead of manually editing the xaml text. I tried to do this using the "Items" collection editor, but it seems to allow subitem properties to be edited, not events. Is there another editor / dialog / etc that allows me to edit subitem events?

Thank you for your help.

John.

P.S: , H.B , xaml.: -)

+3
4

, .

+1

, , , , , - , , , Visual Studio / -MenuItems.

- , XAML , . () XAML, sub-MenuItem, "" "" (F4).

Microsoft , , (?) .

+1

, "edit with visual studio", , ...

xaml:

<MenuItem Name="exitMenuItem" ....>

# codebehind:

exitMenuItem.Click += (s,e) =>
{
    DoIt(); // your event handling code
}
0

"", "", .

2008 , , , , . , - .

0

All Articles