NavBarSection

in namespace DotVVM.Bootstrap5.Controls

Represents an item section in the navigation control.

Usage & Scenarios

Represents an section in NavBar.

https://getbootstrap.com/docs/5.2/components/navbar/

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

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

  • ItemText specifies the property of the collection elements to be used as navigation item text.
  • ItemNavigateUrl specifies the property of the collection elements to be used as navigation item link URL.
  • ItemEnabled specifies the property of the collection elements indicating whether the navigation item is enabled or not.
  • ItemSelected specifies the property of the collection elements indicating whether the navigation item is active or not.
  • ItemClick specifies a command in the viewmodel to be called when the navigation item is clicked.
  • ItemVisible specifies the property of the collection elements indicating whether the navigation item is visible or not.
  • ItemID specifies the property of the collection elements indicating navigation item ID.
  • ItemTemplate specifies a custom template for navigation item.
  • ItemUrlSuffix specifies the property of the collection elements indicating the URL suffix for navigation item.

Sample 1: Generated Navigation Items

The NavBar control cannot directly generate the items from a collection in the viewmodel but can use a NavBarSection control.

<bs:NavBar>
    <BrandTemplate>
        Brand Name
    </BrandTemplate>
    <bs:NavBarSection Datasource="{value: ItemSectionsSource}" ItemText="{value: Text}" ItemNavigateUrl="{value: Url}"/>
    <bs:NavBarText>
        text
    </bs:NavBarText>
</bs:NavBar>

<bs:NavBar>
    <BrandTemplate>
        Brand Name
    </BrandTemplate>
    <bs:NavBarSection Datasource="{value: ItemSectionsSource}" ItemNavigateUrl="{value: Url}"  >
        <ItemTemplate>
            <bs:Icon Type="{value: IconType}" />
            {{value: Text}}
        </ItemTemplate>
    </bs:NavBarSection>
</bs:NavBar>
public class ViewModel
{
    public List<ItemSectionModel> ItemSectionsSource { get; set; }

    public ViewModel()
    {
        ItemSectionsSource = new List<ItemSectionModel>()
        {
            new ItemSectionModel()
            {
                Text = "Riganti",
                Url = "https://riganti.cz/",
                Visible = false,
                IconType = Icons.Window_Desktop
            },
            new ItemSectionModel()
            {
                Text = "Google",
                Url = "https://www.google.com/",
                Selected = true,
                Visible = true,
                IconType = Icons.Window_Dock
            },
        };
    }
}


public class ItemSectionModel
{
    public string Text { get; set; }
    public string Url { get; set; }
    public Icons IconType { get; set; }
    public bool Visible { get; set; }
    public bool Selected { get; set; }
}

Properties

Name Type Description Notes Default Value
property icon DataSource IValueBinding<IEnumerable<Object>> Gets or sets a data-source object from which the child controls will be generated.
attribute
inner element
static value
bindable
default
null
property icon IsScrollable Boolean Gets or sets whether the vertical scrollbar should be displayed when the navigation is collapsed and takes more than 75% of the viewport height.
attribute
inner element
static value
bindable
default
False
property icon ItemEnabled Boolean Gets or sets whether the navigation item is enabled when DataSource is set.
attribute
inner element
static value
bindable
default
True
property icon ItemID String Gets or sets the navigation item ID when DataSource is set.
attribute
inner element
static value
bindable
default
null
property icon ItemNavigateUrl String Gets or sets a URL for navigation item when DataSource is set.
attribute
inner element
static value
bindable
default
null
property icon ItemRouteName String Gets or sets a route name for navigation item when DataSource is set.
attribute
inner element
static value
bindable
default
null
property icon Items List<INavItem> Gets or sets the items inside the control.
attribute
inner element
static value
bindable
default
null
property icon ItemSelected Boolean Gets or sets whether the navigation item is selected when DataSource is set.
attribute
inner element
static value
bindable
default
null
property icon ItemTemplate ITemplate Gets or sets a custom template for navigation item when DataSource is set.
attribute
inner element
static value
bindable
default
null
property icon ItemText String Gets or sets a plain text for navigation item when DataSource is set.
attribute
inner element
static value
bindable
default
null
property icon ItemUrlSuffix String Gets or sets a URL suffix for navigation item when DataSource is set.
attribute
inner element
static value
bindable
default
null
property icon ItemVisible Boolean Gets or sets whether the navigation item is visible when DataSource is set.
attribute
inner element
static value
bindable
default
True
property icon Visible Boolean Gets or sets whether the control is visible. When set to false, `style="display: none"` will be added to this control.
attribute
inner element
static value
bindable
default
True

Events

Name Type Description
event icon ItemClick ICommandBinding Gets or sets a click action for navigation item when DataSource is set.

HTML produced by the control