NavigationBar

in namespace DotVVM.Framework.Controls.Bootstrap4

Renders a Bootstrap Navs widget.

Usage & Scenarios

Renders a Bootstrap Navs widget.

https://getbootstrap.com/docs/4.3/components/navs/

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

Sample 1: Basic Usage

The NavigationBar control has the ItemType property which specified the type of list group items - Default, Link and Button.

Use NavigationItem controls inside the navigation bar.

<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 VisualStyle property specifies how the navigation bar should look like - Tabs, Pills and Simple.

The ItemsLayout property defines whether the navigation items should occupy all available horizontal space.

<bs:NavigationBar VisualStyle="Pills">
    <bs:NavigationItem NavigateUrl="https://www.google.com/" Text="Google" IsSelected="true"/>
    <bs:NavigationItem NavigateUrl="http://www.w3schools.com/html/" Text="W3Schools"/>
</bs:NavigationBar>
<br />
<bs:NavigationBar VisualStyle="Tabs">
    <bs:NavigationItem NavigateUrl="https://www.google.com/" Text="Google" IsSelected="true"/>
    <bs:NavigationItem NavigateUrl="http://www.w3schools.com/html/" Text="W3Schools"/>
</bs:NavigationBar>
<br />
<bs:NavigationBar ItemsLayout="StretchEvenly">
    <bs:NavigationItem NavigateUrl="https://www.google.com/" Text="Google" IsSelected="true"/>
    <bs:NavigationItem NavigateUrl="http://www.w3schools.com/html/" Text="W3Schools"/>
</bs:NavigationBar>
<br />
<bs:NavigationBar ItemsLayout="Stretch">
    <bs:NavigationItem NavigateUrl="https://www.google.com/" Text="Google" IsSelected="true"/>
    <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
  • IsEnabledBinding
  • IsSelectedBinding
  • NavigateUrlBinding
  • TextBinding
<bs:NavigationBar Type="Pills" IsJustified="true" 
                  DataSource="{value: LinksDataSet}" 
                  IsEnabledBinding="{value: IsEnabled}" 
                  IsSelectedBinding="{value: IsSelected}"
                  TextBinding="{value: Text}" 
                  NavigateUrlBinding="{value:  NavigateUrl}" />
public class ViewModel
{
    public List<NavigationItem> LinksDataSet { get; set; }

    private static IQueryable<NavigationItem> GetData()
    {
        return new[]
        {
            new NavigationItem() { IsEnabled = true, IsSelected = false, NavigateUrl = "https://www.google.com/", Text = "Google" },
            new NavigationItem() { IsEnabled = true, IsSelected = false, NavigateUrl = "http://www.w3schools.com/html/", Text = "W3Schools" },
            new NavigationItem() { IsEnabled = true, IsSelected = true, NavigateUrl = "https://www.microsoft.com/en-us/", Text = "Microsoft" },
            new NavigationItem() { IsEnabled = false, IsSelected = false, 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 IsEnabled { get; set; }
}

Properties

Name Type Description Notes Default Value
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 IsEnabledBinding 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 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<INavigationItem> 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 ItemsContentTemplate ITemplate Gets or sets the template for contents of the generated items when using the DataSource property.
attribute
inner element
static value
bindable
default
null
property icon ItemsLayout ItemsLayout Gets or sets layout of inner items.
attribute
inner element
static value
bindable
default
Default
property icon ItemType NavigationItemType Gets or sets the type of the items.
attribute
inner element
static value
bindable
default
Default
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 ScrollSpyEnabled Boolean
attribute
inner element
static value
bindable
default
False
property icon ScrollSpyOffset Int32
attribute
inner element
static value
bindable
default
10
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 VisualStyle NavigationBarVisualStyle Gets or sets the type of the navigation bar.
attribute
inner element
static value
bindable
default
Tabs

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