Latest News

  • Super Tower Defense 2 Game
    Sep 03, 2010

    New to the games section is Super Tower Defense 2. Featuring more maps, new units and bigger explosions.

  • Super Cards Online Multiplayer Game
    Aug 13, 2010

    Released today in the games section is the new Super Cards multiplayer card game. The aim of the game is to get rid of all your playing cards before your opposition.

  • Silverlight Online Chat
    Jul 24, 2010

    Today we launch the new Silverlight Live Chat application demonstrating the Liquid RichTextBox and Emoticon replacements.

  • New Super Shoot Em Up 2 Game
    Jun 29, 2010

    Added to the Games section is the new Super Shoot 'Em Up 2 game. Take control of your tank with the aim to defeat the computer controlled opponents. Features all new weapons, levels and Battle Mode!

  • Silverlight 4 Controls V5.3.2 Released
    Jun 28, 2010

    This release contains several fixes raised in the forums.

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

Latest Forum Posts

Here are latest posts from around the forums, if you have a question about any of the Liquid controls you can get your answers in the Forum.

robotuner posted on Silverlight4 DataGrid?

Is the menu supported in sl4 datagrids?  In sl4 there is now right mouse click support, so I can get to

        private void DataGrid_MouseRightButtonUp(object sender, MouseButtonEventArgs e)

        {

             popupMenu.Show();

        }

but nothing happens.  So I'm thinking it isn't supported or I have not configured something properly (more likely).  I haven't been able to figure out how to specify the position of the menu, so it might be showing out in space.

I've embedded in within the datagrid xaml:


<Grid x:Name="LayoutRoot">

   <Grid.Resources>

   </Grid.Resources>

   <StackPanel Orientation="Vertical">

     <Grid x:Grid1>

        <Grid.RowDefinitions>

               <RowDefinition Height="Auto" />

         </Grid.RowDefinitions>

         <liquidMenu:Menu x:Name="popupMenu" Width="40" Height="40"                            

                    ItemSelected="MenuList_ItemSelected" Visibility="Collapsed">

                        <liquidMenu:MenuItem ID="delete"  Text="delete" Shortcut="Ctrl+D" />

                        <liquidMenu:MenuItem ID="insert"  Text="insert" Shortcut="Ctrl+I" />

          </liquidMenu:Menu>

     </Grid>

  </stackPanel>

<Grid>


Any suggestions of help would be appreciated!!

Thanks.

TuanAnh207 posted on How to hide a menu when lost focus

Hi, I'm having a problem that i don't know how to close a menu when i click on a space out of the menu!

Can anyone help me ?


Thanks!

TuanAnh207 posted on Access to menu items

this.testMenu.Get("System_LogOut").IsEnabled = false;

This is what i have done before. Hope it can help you in some way !

Hi all,

           i can't able to add  Liquid.Menu.dll reference to my application.i am getting an error

Cool, thanks for sharing this!

Hi Milos,


Thanks for this.  The MousePlus class was implemented in SL3 to overcome the lack of a right mouse click but as you've seen Silverlight 4 now has native support for the right mouse button.


Thanks!

Rate this page: 

1 Star 2 Star 3 Star 4 Star 5 Star
14 Ratings / 2.9 Average

Ultimate Gamers

  • 1 Gh0sT
  • 2 stig
  • 3 dhoz
  • 4 seyhmusss
  • 5 RadiateLogic
  • 6 bigblue531
  • 7 janso
  • 8 DutchRemco
  • 9 Gendibal
  • 10 dan

  • See the full chart here!

Silverlight Controls

  • Rich TextBox

    Create and edit rich content with this slick and expandable Rich TextBox...

  • TreeView

    This easy to use TreeView comes with drag and drop, sorting, searching and much more...

  • Context Menu

    You too can have cool popup context menus in your Silverlight applications...

  • Resizable Dialog

    Draggable and resizable popup dialogs are what serious Silverlight developers need...

  • Spell Checker

    Real-time spell checking in Silverlight? We did it first here...