Version:
2.0

ToggleButton

in namespace DotVVM.BusinessPack.Controls

Properties

Name Type Description Notes Default Value
property icon Checked Boolean
attribute
inner element
static value
bindable
default
False
property icon Enabled Boolean
attribute
inner element
static value
bindable
default
False
property icon Text String
attribute
inner element
static value
bindable
default

Events

Name Type Description
event icon Click Command

Usage & Scenarios

Renders the HTML button that can switch states like the CheckBox

HTML Rendered by the Control

Sample 1: Basic Usage

The ToggleButton control has the Checked property of boolean which indicates whether the control is checked or not.

You can use the Text property to specify the button text. Or you can put contents inside the bp:ToggleButton element.

<bp:ToggleButton Text="Toggle button" Checked="{value: Checked}"/>
using System;
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.businesspack.ToggleButton.sample1
{
    public class ViewModel : DotvvmViewModelBase
    {
        public bool Checked { get; set; }
    }
}

Sample 1: Basic Usage

You can set which command will be triggered when the button is clicked with click property.

<bp:ToggleButton Checked="{value: Checked}"
                 Click="{command: ClickCount = ClickCount + 1}">
    <span>Toggle button</span>
</bp:ToggleButton>

<p>Click counter: {{value: ClickCount}}</p>
using System;
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.businesspack.ToggleButton.sample2
{
    public class ViewModel : DotvvmViewModelBase
    {
        public bool Checked { get; set; }
        public int ClickCount { 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.

Edit on Github

Send message