ListGroupItem

in namespace DotVVM.Framework.Controls.Bootstrap

Represents an item in the ListGroup control.

Usage & Scenarios

This control is used as a list item inside the ListGroup control.

The ListGroupItem derives from the ListItem and it adds several features to it specific for ListGroup.

Sample 1: Basic ListGroupItem

The ListGroupItem control contains Text property which displays text in the generated item.

The URL for link items can be specified using bindable NavigateUrl property.

You can specify the color of the item with the Color property using Bootstrap styling for items (Success, Info, Warning, Danger).

Additionally, you can add a badge text to the right side of the list item, using bindable Badge property. If this property is empty, empty badge will not be displayed.

<bs:ListGroup>
  <bs:ListGroupItem Text="Item 1" Color="Info" NavigateUrl="https://www.dotvvm.com"/>
  <bs:ListGroupItem Text="Item 2" Color="Success" Badge="This is success ListGroupItem" />
  <bs:ListGroupItem Text="Item 3" Color="Warning" />
  <bs:ListGroupItem Text="Item 4" Color="Danger" />
  <bs:ListGroupItem Text="Item 5" Badge="This is badge" />
</bs:ListGroup>

Sample 2: ListGroupItem - Item Types, Bindings & Other Properties

Similarly to Bootstrap each ListGroupItem can have different type. ItemType property specify what type of item will be generated. Expected values are Link which generates "a" element, Button which generates "button" element. Default generated element is "li".

Additionally the ListGroupItem control has the IsDisabled and IsSelected properties.

You can also use GlyphIcon or any other kind of HTML content inside the control.

<bs:ListGroup ItemType="Button">
  <bs:ListGroupItem Text="Item 1" Color="Info" />
  <bs:ListGroupItem Text="Item 2" Color="Success" IsDisabled="true" />
  <bs:ListGroupItem Text="Item 3" Color="Warning" IsSelected="true" />
  <bs:ListGroupItem Text="Item 4" Color="Danger" />
</bs:ListGroup>

<bs:ListGroup ItemType="Link">
  <bs:ListGroupItem Text="Google Link" NavigateUrl="https://www.google.com/" Color="Success"/>
  <bs:ListGroupItem Text="DotVVM" NavigateUrl="{value: NavigateUrl}" />
</bs:ListGroup>

<bs:ListGroup>
  <bs:ListGroupItem Text="Item 1" Badge="Simple Badge" />
  <bs:ListGroupItem Color="Info">
    <bs:GlyphIcon Icon="Info_sign" /> info
  </bs:ListGroupItem>
  <bs:ListGroupItem Text="Item 3" Badge="{value: BadgeText}" />
  <bs:ListGroupItem IsDisabled="true">
    <bs:GlyphIcon Icon="Music" />
  </bs:ListGroupItem>
</bs:ListGroup>
using DotVVM.Framework.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace DotvvmWeb.Views.Docs.Controls.bootstrap.ListGroupItem.sample2
{
    public class ViewModel : DotvvmViewModelBase
    {
        public string BadgeText { get; set; } = "Bound Badge Text From View Model";

        public string NavigateUrl { get; set; } = "https://www.dotvvm.com";
    }
}

Properties

Name Type Description Notes Default Value
property icon Badge String Gets or sets the text that appears in the badge. If the text is empty, no badge will be displayed.
attribute
inner element
static value
bindable
default
null
property icon Color ContextualColor Gets or sets the color of the list item. (Based on bootstrap list group styles.)
attribute
inner element
static value
bindable
default
Default
property icon IsDisabled Boolean Gets or sets whether this item is disabled.
attribute
inner element
static value
bindable
default
False
property icon IsSelected Boolean Gets or sets whether this item is selected.
attribute
inner element
static value
bindable
default
False
property icon NavigateUrl String Gets or sets the URL of the item hyperlink.
attribute
inner element
static value
bindable
default
property icon RouteName String Gets or sets the name of the route for the item hyperlink.
attribute
inner element
static value
bindable
default
null
property icon Text String Gets or sets the text of the item.
attribute
inner element
static value
bindable
default
property icon UrlSuffix String Gets or sets the suffix that will be appended to the generated URL.
attribute
inner element
static value
bindable
default
null

Events

Name Type Description
event icon Click Action Gets or sets the command that will be triggered when the button is clicked.

HTML produced by the control