Warning: Table './planetar_drpl3/sessions' is marked as crashed and should be repaired query: SELECT u.*, s.* FROM users u INNER JOIN sessions s ON u.uid = s.uid WHERE s.sid = 'e289370fbd3c5d19fbf33c2071505a5c' in /home/planetar/public_html/blendtips/includes/database.mysql.inc on line 172

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/planetar/public_html/blendtips/includes/database.mysql.inc:172) in /home/planetar/public_html/blendtips/includes/bootstrap.inc on line 811

Warning: Cannot modify header information - headers already sent by (output started at /home/planetar/public_html/blendtips/includes/database.mysql.inc:172) in /home/planetar/public_html/blendtips/includes/bootstrap.inc on line 488

Warning: Cannot modify header information - headers already sent by (output started at /home/planetar/public_html/blendtips/includes/database.mysql.inc:172) in /home/planetar/public_html/blendtips/includes/bootstrap.inc on line 489

Warning: Cannot modify header information - headers already sent by (output started at /home/planetar/public_html/blendtips/includes/database.mysql.inc:172) in /home/planetar/public_html/blendtips/includes/bootstrap.inc on line 490

Warning: Cannot modify header information - headers already sent by (output started at /home/planetar/public_html/blendtips/includes/database.mysql.inc:172) in /home/planetar/public_html/blendtips/includes/bootstrap.inc on line 491
Tutorial: Adding context menus | Drupal

Tutorial: Adding context menus

warning: Cannot modify header information - headers already sent by (output started at /home/planetar/public_html/blendtips/includes/database.mysql.inc:172) in /home/planetar/public_html/blendtips/includes/common.inc on line 141.


Context menus are not available to be created in a WYSIWIG way like you can create almost everything else for your user interface in Blend. On the one hand, this makes creating context menus, slightly annoying, and on the other hand, it makes you appreciate the ease in which you can create almost everything else with Blend. Here's the basic steps for creating context menus.Part 1 describes how to create it, and part 2 describes how to add events.
Creating the Context Menu
1)Select the item that you want the context menu to apply to.
2)In the Miscellaneous palette, click the New button beside Context Menu. This opens up a panel with lots of options.
3)Scroll down and click the button beside Items (Collection) to bring up the Collection Editor.
4)In the Collection Editor click Add Another Item. This brings up the Select Object dialog box.
5)In the Search box, type Menu, and then select Menu from the list and click OK.
6)In the Collection Editor you can use the Properties panel on the right to assign values to define the look of the menu.
7)In the Common Properties palette in the Collection Editor, click the button beside Items (Collection).
8)Click the Add Another Item button and type Menu into the Search field again. This time, choose MenuItem. Then type in its Header property in the Common Properties palette. And repeat this for as many menu items that you want. (To nest menu items, click the Items (Collection) button instead of Add Another Item button.)
9)Click OK when all your items are added. Click OK again to exit the Collection Editor.
10) Test your context menu.
Adding events to the menu items of the context menu
To add events to the menu items, so that they function, you need to manually enter the events in the XAML. The following is an example of the XAML of a simple context menu.
<Ellipse Fill="#FF7CC137" Stroke="#FF000000" Margin="140,93,102,97">
   <Ellipse.ContextMenu>
       <ContextMenu>
         <Menu>
             <MenuItem Header="Save">
            <MenuItem Header="Open">
            <MenuItem Header="Close">
         </Menu>
       </ContextMenu>
   </Ellipse.ContextMenu>
</Ellipse>
Now it's just a matter of adding the Event=”EventHandlerName” for each MenuItem. However, adding events in XAML do not automatically set up the event handler in the code-behind file. One thing you may want to do first, is create the entire menu in the same window or page without it being a context menu, just to add the event handlers, then when you delete the menu, the event handlers do not get deleted. You can then create the menu again as a context menu and easily add all the event handlers by hand in the XAML.