Version: 2.0 |

NavigationBar

in namespace DotVVM.Framework.Controls.Bootstrap4

Renders a Bootstrap Navs widget.

Properties

Name Type Description Notes Default Value
ClickBinding ICommandBinding Gets or sets a binding which defines a click action for button items.
attribute
inner element
static value
bindable
default
DataSource Object Gets or sets the source collection or a GridViewDataSet that contains data in the control.
attribute
inner element
static value
bindable
default
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
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
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
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
ItemsLayout ItemsLayout Gets or sets layout of inner items.
attribute
inner element
static value
bindable
default
Default
ItemType NavigationItemType Gets or sets the type of the items.
attribute
inner element
static value
bindable
default
Default
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
ScrollSpyEnabled Boolean
attribute
inner element
static value
bindable
default
False
ScrollSpyOffset Int32
attribute
inner element
static value
bindable
default
10
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
VisualStyle NavigationBarVisualStyle Gets or sets the type of the navigation bar.
attribute
inner element
static value
bindable
default
Tabs

Events

Name Type Description

Usage & Scenarios

Renders a Bootstrap Navs widget.

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

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

HTML Rendered by the Control

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 IsFilled property defines whether the navigation bar takes all available horizontal space.

The IsJustified property defines whether the navigation items should have equal width.

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

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

<bs:NavigationBar IsFilled="true">
    <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
  • IsEnabledBinding
  • 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; }
    }
}

Suggestions


Help & Contribute

The documentation is maintained on GitHub.
We'll be happy if you edit the page and create a pull request.

Send message