NavigationBar

in namespace DotVVM.Framework.Controls.Bootstrap

Renders a Bootstrap Navs widget.

Usage & Scenarios

Renders a Bootstrap Navs widget.

http://getbootstrap.com/components/#nav

If you want to create a responsive menu (NavBar), use the ResponsiveNavigation control instead.

Sample 1: Basic Usage

The NavigationItem control has the NavigateUrl property which specifies target URL, or the Click property which invokes a command on the viewmodel.

The Text property defines the contents of the item. Alternatively, you can also place the contents inside the control.

The IsSelected and IsDisabled properties define whether the control gets the active or disabled CSS classes.

<bs:NavigationBar>
    <bs:NavigationItem NavigateUrl="https://www.google.com/" 
                          Text="Google" 
                          IsSelected="true" />
    <bs:NavigationItem NavigateUrl="http://www.w3schools.com/html/" 
                          Text="W3 Schools" 
                          IsDisabled="true" />
</bs:NavigationBar>

Sample 2: NavigationBar Appearance

The Type and IsJustified properties can modify the visual appearance of the navigation bar.

<bs:NavigationBar Type="Pills">
    <bs:NavigationItem NavigateUrl="https://www.google.com/" Text="Google"/>
    <bs:NavigationItem NavigateUrl="http://www.w3schools.com/html/" Text="W3Schools"/>
</bs:NavigationBar>

<bs:NavigationBar Type="PillsStacked">
    <bs:NavigationItem NavigateUrl="https://www.google.com/" Text="Google"/>
    <bs:NavigationItem NavigateUrl="http://www.w3schools.com/html/" Text="W3Schools"/>
</bs:NavigationBar>

<bs:NavigationBar Type="Tabs">
    <bs:NavigationItem NavigateUrl="https://www.google.com/" Text="Google"/>
    <bs:NavigationItem NavigateUrl="http://www.w3schools.com/html/" Text="W3Schools"/>
</bs:NavigationBar>

<bs:NavigationBar IsJustified="true">
    <bs:NavigationItem NavigateUrl="https://www.google.com/" Text="Google"/>
    <bs:NavigationItem NavigateUrl="http://www.w3schools.com/html/" Text="W3Schools"/>
</bs:NavigationBar>

Sample 3: Data Binding Navigation Items

The NavigationBar control can also generate the items from a collection in the viewmodel.

The DataSource property define the collection of objects which will be used to create the list items.

Using the following properties, you can specify, which properties of objects in the collection will be used to configure the navigation items.

  • ClickBinding
  • IsDisabledBinding
  • IsSelectedBinding
  • NavigateUrlBinding
  • TextBinding
<bs:NavigationBar Type="Pills" IsJustified="true" 
                  DataSource="{value: LinksDataSet}" 
                  IsDisabledBinding="{value: IsDisabled}" 
                  IsSelectedBinding="{value: IsSelected}"
                  TextBinding="{value: Text}" 
                  NavigateUrlBinding="{value:  NavigateUrl}" />
using System.Collections.Generic;
using System.Linq;

namespace DotvvmWeb.Views.Docs.Controls.bootstrap.NavigationBar.sample3
{
    public class ViewModel
    {
        public List<NavigationItem> LinksDataSet { get; set; }

        private static IQueryable<NavigationItem> GetData()
        {
            return new[]
            {
                new NavigationItem() { NavigateUrl = "https://www.google.com/", Text = "Google" },
                new NavigationItem() { NavigateUrl = "http://www.w3schools.com/html/", Text = "W3Schools" },
                new NavigationItem() { IsSelected = true, NavigateUrl = "https://www.microsoft.com/en-us/", Text = "Microsoft" },
                new NavigationItem() { IsDisabled = true, NavigateUrl = "https://github.com/riganti/dotvvm", Text = "DotVVM Github" }
            }.AsQueryable();
        }

        public ViewModel()
        {
            LinksDataSet = new List<NavigationItem>();
            foreach (NavigationItem l in GetData())
            {
                LinksDataSet.Add(l);
            }
        }


    }


    public class NavigationItem
    {
        public string Text { get; set; }
        public string NavigateUrl { get; set; }
        public bool IsSelected { get; set; }
        public bool IsDisabled { get; set; }
    }
}

Properties

Name Type Description Notes Default Value
property icon ClientIDMode ClientIDMode Gets or sets the client ID generation algorithm.
attribute
inner element
static value
bindable
default
1
property icon DataContext Object Gets or sets a data context for the control and its children. All value and command bindings are evaluated in context of this value.
attribute
inner element
static value
bindable
default
null
property icon DataSource Object Gets or sets the source collection or a GridViewDataSet that contains data in the control.
attribute
inner element
static value
bindable
default
null
property icon ID String Gets or sets the unique control ID.
attribute
inner element
static value
bindable
default
null
property icon InnerText String Gets or sets the inner text of the HTML element.
attribute
inner element
static value
bindable
default
null
property icon IsDisabledBinding IValueBinding Gets or sets a value binding that points to a property indicating whether the item is disabled or not.
attribute
inner element
static value
bindable
default
null
property icon IsJustified Boolean Gets or sets whether the items should be justified to fill all available space in the horizontal direction.
attribute
inner element
static value
bindable
default
False
property icon IsSelectedBinding IValueBinding Gets or sets a value binding that points to a property indicating whether the item is selected or not.
attribute
inner element
static value
bindable
default
null
property icon Items List<IListItem> Gets or sets a collection of items that is used when no DataSource is set.
attribute
inner element
static value
bindable
default
null
property icon NavigateUrlBinding IValueBinding Gets or sets the value binding that points to a property which will be navigated to when the item is clicked.
attribute
inner element
static value
bindable
default
null
property icon TextBinding IValueBinding Gets or sets the value binding that points to a property which will be used as the text of the item.
attribute
inner element
static value
bindable
default
null
property icon Type NavigationBarType Gets or sets the type of the navigation bar.
attribute
inner element
static value
bindable
default
0
property icon Visible Boolean Gets or sets whether the control is visible.
attribute
inner element
static value
bindable
default
True

Events

Name Type Description
event icon ClickBinding ICommandBinding Gets or sets a binding which defines a click action for button items.

HTML produced by the control