Silverlight Main Menu

This free Main Menu control provides Silverlight developers with an easy to use and customizable drop down menu system with a familiar default style.

This Silverlight only Main Menu Control is easy to implement on your Silverlight driven website and is also customizable to provide a visual feel suitable for any site design.

To use the Main Menu control you will need to add a reference to Liquid.Menu.dll in your project.

How to Use the Main Menu Control

To use the Main Menu on your Silverlight page:

<UserControl x:Class="MainMenu.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:liquidMenu="clr-namespace:Liquid;assembly=Liquid.Menu"
    Width="400" Height="300">
    <Canvas x:Name="LayoutRoot" Background="White">
        <liquidMenu:MainMenu x:Name="testMenu" ItemSelected="testMenu_ItemSelected">
            <liquidMenu:MainMenu.Items>
                <liquidMenu:MainMenuItem Text="Menu 1">
                    <liquidMenu:Menu>
                        <liquidMenu:MenuItem ID="item11" Icon="images/document.png" Text="Item 1" />
                        <liquidMenu:MenuDivider />
                        <liquidMenu:MenuItem ID="item12" Icon="images/save.png" Shortcut="Ctrl+S" Text="Item 2" />
                        <liquidMenu:MenuDivider />
                        <liquidMenu:MenuItem ID="item13" Text="Item 3" />
                    </liquidMenu:Menu>
                </liquidMenu:MainMenuItem>
                <liquidMenu:MainMenuItem Text="Menu 2">
                    <liquidMenu:Menu>
                        <liquidMenu:MenuItem ID="item21" Text="Item 1" />
                        <liquidMenu:MenuItem ID="item22" Text="Item 2" />
                        <liquidMenu:MenuItem ID="item23" Text="Item 3" />
                    </liquidMenu:Menu>
                </liquidMenu:MainMenuItem>
                <liquidMenu:MainMenuItem Text="Menu 3">
                    <liquidMenu:Menu>
                        <liquidMenu:MenuItem ID="item31" Text="Item 1" />
                        <liquidMenu:MenuItem ID="item32" Text="Item 2" />
                        <liquidMenu:MenuDivider />
                        <liquidMenu:MenuItem ID="item33" Text="Item 3" />
                    </liquidMenu:Menu>
                </liquidMenu:MainMenuItem>
            </liquidMenu:MainMenu.Items>
        </liquidMenu:MainMenu>
    </Canvas>
</UserControl>


Here we have a menu with the name testMenu, this contains three child menus.  Each of these have child menu options, they can be nested as deep as required.

Note we assign an ID to each menu item, this allows us to detect which item has been selected using the ItemSelected event which you can see below.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using Liquid;

namespace MainMenu
{
    public partial class Page : UserControl
    {
        public Page()
        {
            InitializeComponent();
        }

        private void testMenu_ItemSelected(object sender, MenuEventArgs e)
        {
            switch (e.Tag.ToString())
            {
                case "item11":
                    // TODO: New functionality
                    break;
                case "item12":
                    // TODO: Save functionality
                    break;
            }
        }
    }
}


The MenuList_ItemSelected event handler is called each time an item is selected.  The argument object passed in contains a Tag property which contains the ID of the item that generated the event.

The menu control used here can display images and keyboard shortcuts as well as the title text.

Example Silverlight Main Menu Control:

Silverlight Main Menu Control

Further Information

Post your Comments

 
Latest Games
Zombie Escape
Apr 19, 2016
Plays: 1,346

Zombie Escape ScreenshotDrive fast before the crazy mutant zombies get you!

6 Ratings/4.1 Average
Car Parking
Jan 16, 2016
Plays: 1,327

Car Parking ScreenshotGuide the car to its parking space in this fun Car Parking game.

1 Rating/5 Average
Trash It
Jan 11, 2016
Plays: 1,212

Trash It ScreenshotAim for the Trash Can and get the various items of Trash in the bin.

4 Ratings/5 Average
Sky Fly
Jan 11, 2016
Plays: 1,339

Sky Fly ScreenshotFly your plane in this colorful vertical scrolling shoot-em-up. Blast the bad guys and collect any bonus's they leave behind.

1 Rating/5 Average
Professor Snappy
Jan 11, 2016
Plays: 978

Professor Snappy ScreenshotPop as many bubbles as possible in this fun and colorful bubble popping game. The levels start off easy enough but gradually get harder!

1 Rating/5 Average
Monster Match Saga
Jan 10, 2016
Plays: 1,302

Monster Match Saga ScreenshotHere we have a bunch of monsters that need to be matched up. Look out for the bomb and spinning monsters that will cause special damage!

3 Ratings/4.6 Average
Fly Bird Fly
Jan 10, 2016
Plays: 1,022

Fly Bird Fly ScreenshotGuide your friendly Bird through the maze of pipes and other obstacles collecting the Stars in this cool arcade game inspired by the legendary Flappy Bird.

1 Rating/5 Average
Life In One
Jan 10, 2016
Plays: 1,233

Life In One ScreenshotYou are stranded on an Alien planet. Your goal is to build a space rocket and escape. Start by building units to create power and mine the metal patches. Build defenses to defend your base from the advancing Aliens and Zombies!

2 Ratings/3 Average
X Pool
Jan 02, 2016
Plays: 1,708

X Pool ScreenshotPlay Pool against the computer or battle against your friends in the online mode!

3 Ratings/3 Average
Fruit Slicer
Jan 02, 2016
Plays: 973

Fruit Slicer ScreenshotSlice the fruit that is thrown up onto the screen. Slice the fruit into multiple pieces for maximum points!

1 Rating/5 Average