CheckBox
in namespace DotVVM.Framework.Controls.Bootstrap
Extends the default CheckBox control with additional Bootstrap features.
Usage & Scenarios
Extends the builtin CheckBox control with an option to set Bootstrap CSS classes and support of the ButtonGroup.
Sample 1: Inline CheckBoxes
The IsInline
property allows to render checkboxes on one row.
If the CheckBox
es are placed inside the ButtonGroup control, they are set to inline by default so you don't have to change anything.
<bs:CheckBox Text="CheckBox 1" Checked="{value: Checked1}" IsInline="true" />
<bs:CheckBox Text="CheckBox 2" Checked="{value: Checked2}" IsInline="true"/>
<p>CheckBox 1: {{value: Checked1}}</p>
<p>CheckBox 2: {{value: Checked2}}</p>
using DotVVM.Framework.ViewModel;
namespace DotvvmWeb.Views.Docs.Controls.bootstrap.CheckBox.sample1
{
public class ViewModel : DotvvmViewModelBase
{
public bool Checked1 { get; set; }
public bool Checked2 { get; set; }
}
}
Sample 2: CheckBox in ButtonGroup
You can change the color of the CheckBox
using the Type
property.
This property works only inside the ButtonGroup control.
<bs:ButtonGroup>
<bs:CheckBox Checked="{value: Checked1}" Text="CheckBox - Primary" Type="Primary" />
</bs:ButtonGroup>
<bs:ButtonGroup>
<bs:CheckBox Checked="{value: Checked2}" Text="CheckBox - Success" Type="Success" />
</bs:ButtonGroup>
<bs:ButtonGroup>
<bs:CheckBox Checked="{value: Checked3}" Text="CheckBox - Info" Type="Info" />
</bs:ButtonGroup>
<bs:ButtonGroup>
<bs:CheckBox Checked="{value: Checked4}" Text="CheckBox - Warning" Type="Warning" />
</bs:ButtonGroup>
<bs:ButtonGroup>
<bs:CheckBox Checked="{value: Checked5}" Text="CheckBox - Danger" Type="Danger" />
</bs:ButtonGroup>
<p>CheckBox - Primary: {{value: Checked1}}</p>
<p>CheckBox - Success: {{value: Checked2}}</p>
<p>CheckBox - Info: {{value: Checked3}}</p>
<p>CheckBox - Warning: {{value: Checked4}}</p>
<p>CheckBox - Danger: {{value: Checked5}}</p>
using DotVVM.Framework.ViewModel;
namespace DotvvmWeb.Views.Docs.Controls.bootstrap.CheckBox.sample2
{
public class ViewModel : DotvvmViewModelBase
{
public bool Checked1 { get; set; }
public bool Checked2 { get; set; }
public bool Checked3 { get; set; }
public bool Checked4 { get; set; }
public bool Checked5 { get; set; }
}
}
Properties
Name | Type | Description | Notes | Default Value | |
---|---|---|---|---|---|
Checked | Boolean | Gets or sets whether the control is checked. |
attribute
bindable
|
False | |
CheckedItems | IEnumerable | Gets or sets a collection of values of all checked checkboxes. Use this property in combination with the CheckedValue property. |
attribute
static value
bindable
|
null | |
CheckedValue | Object | Gets or sets the value that will be used as a result when the control is checked. Use this property in combination with the CheckedItem or CheckedItems property. |
attribute
static value
bindable
|
null | |
ClientIDMode | ClientIDMode | Gets or sets the client ID generation algorithm. |
attribute
static value
|
1 | |
DataContext | Object | Gets or sets a data context for the control and its children. All value and command bindings are evaluated in context of this value. |
attribute
static value
bindable
|
null | |
Enabled | Boolean | Gets or sets a value indicating whether the control is enabled and can be clicked on. |
attribute
static value
bindable
|
True | |
ID | String | Gets or sets the unique control ID. |
attribute
static value
|
null | |
InnerText | String | Gets or sets the inner text of the HTML element. |
attribute
static value
bindable
|
null | |
IsInline | Boolean | Gets or sets whether there will be more checkboxes on the same line. When this propererty is true, the checkbox gets the Boostrap "inline" CSS class. |
attribute
static value
bindable
|
False | |
Text | String | Gets or sets the label text that is rendered next to the control. |
attribute
static value
bindable
|
||
Type | BootstrapColor | Gets or sets the Bootstrap color. |
attribute
static value
bindable
|
0 | |
Visible | Boolean | Gets or sets whether the control is visible. |
attribute
bindable
|
True |
Events
Name | Type | Description | |
---|---|---|---|
Changed | Command | Gets or sets the command that will be triggered when the control check state is changed. |