Menu
Context Menu
Context menus are menus that appear upon user interaction, typically a right-click, and display commands that apply to the object that was clicked.
Features
I have a Context Menu.
I have the same Context Menu.
You guessed it! Me too.
Change BackgroundColor
Description
Context menus are menus that appear upon user interaction, typically a right-click, and display commands that apply to the object that was clicked.
We can set the context menu by setting the Owner property.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace MvcExplorer.Controllers { public partial class MenuController : Controller { public ActionResult ContextMenu() { return View(); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | @section Styles{ < style > .context { margin: 10px; padding: 20px; color: white; display: inline-block; } </ style > } @section Scripts{ <script> function setColor(arg) { wijmo.Control.getControl( "#ctxMenu" ).owner.style.background = arg; } </script> } < label > @Html .Raw(Resources.Menu.ContextMenu_Text0)</ label > < div class = "context" style = "background:#f0a0a0" > @Html .Raw(Resources.Menu.ContextMenu_Text1) </ div > < div class = "context" style = "background:#a0f0a0" > @Html .Raw(Resources.Menu.ContextMenu_Text2) </ div > < div class = "context" style = "background:#a0a0f0" > @Html .Raw(Resources.Menu.ContextMenu_Text3) </ div > @ (Html.C1().Menu().Header(Resources.Menu.ContextMenu_Text4) .Id( "ctxMenu" ) .Command( "setColor" ) .MenuItems(items => { items.Add(Resources.Menu.ContextMenu_ColorPink, "#f0a0a0" ); items.Add(Resources.Menu.ContextMenu_ColorAqua, "#a0f0a0" ); items.Add(Resources.Menu.ContextMenu_ColorPurple, "#a0a0f0" ); items.Add(Resources.Menu.ContextMenu_ColorBlue, "blue" ); items.Add(Resources.Menu.ContextMenu_ColorRed, "red" ); items.Add(Resources.Menu.ContextMenu_ColorYellow, "yellow" ); }) .CssStyle( "display" , "none" ) .Owner( ".context" ) ) @section Description{ @Html .Raw(Resources.Menu.ContextMenu_Text5) } |