Skip to main content

MenuSettings.Orientation Property

Gets or sets the direction in which to render the menu.

Namespace: DevExpress.Web.Mvc

Assembly: DevExpress.Web.Mvc5.v24.1.dll

NuGet Package: DevExpress.Web.Mvc5

Declaration

public Orientation Orientation { get; set; }

Property Value

Type Description
Orientation

One of the Orientation enumeration values.

Remarks

Items can be arranged within a menu one after another, either vertically or horizontally. Use the Orientation property to control the arrangement of items.

Example

In the code sample below, the Menu control is bound to a Site Map data source. An item’s NavigateUrl and Text property values are automatically retrieved from the url and title Site Map node attributes respectively (to learn more, see the Automatic Data Binding topic). The ItemDataBound event is handled for two purposes.

  1. To add an image sprite CSS class to items that have the corresponding attribute (“SpriteImage”) within the data source.
  2. To bold a score and add it to text of items that have the corresponding attribute (“result”) within the data source.

The image below shows the result.

ASPxMenu_DataBindingEvents

You can see the complete sample in the Menu - Data Binding to SiteMap on-line demo.

@Html.DevExpress().Menu(settings => {
    settings.Name = "mDataBinding";
    settings.AllowSelectItem = true;
    settings.EncodeHtml = false;
    settings.Orientation = Orientation.Vertical;
    settings.Styles.SubMenuItem.ImageSpacing = 8;
    settings.Width = 100;

    settings.ItemDataBound = (sender, e) => {
        var node = e.Item.DataItem as SiteMapNode;
        if(node != null) {
            if(!string.IsNullOrEmpty(node["SpriteImage"]))
                e.Item.Image.SpriteProperties.CssClass = node["SpriteImage"];
            e.Item.Text = "<b>" + node["result"] + "</b> " + e.Item.Text;
        }
    };
}).BindToSiteMap("~/App_Data/WorldCup2010.sitemap", false).GetHtml()
See Also