DropDownButton
in namespace DotVVM.BusinessPack.Controls
Renders the HTML button displaying a popup panel on click.
Usage & Scenarios
DropDownButton opens a popup containing controls or markup you provide.
Sample 1: Choosing display options
Use Text for a simple caption and ToggleIcon to replace its arrow. For a custom caption, supply ContentTemplate instead; include any icon in that template.
Both buttons use PopupTemplate to let you change the preview. The first binds IsExpanded so the popup can close itself. Clear the Enable color options checkbox to try the second button's Enabled state.
<bp:DropDownButton Text="Text options" IsExpanded="{value: Expanded}">
<ToggleIcon><bp:Icon Icon="Plus" /></ToggleIcon>
<PopupTemplate>
<bp:CheckBox Text="Bold" Checked="{value: Bold}" />
<bp:Button Text="Done" Click="{staticCommand: Expanded = false}" />
</PopupTemplate>
</bp:DropDownButton>
<bp:CheckBox Text="Enable color options" Checked="{value: ColorsEnabled}" />
<bp:DropDownButton Enabled="{value: ColorsEnabled}">
<ContentTemplate><bp:Icon Icon="Pallete" /> Color options</ContentTemplate>
<PopupTemplate>
<bp:CheckBox Text="Highlight" Checked="{value: Highlight}" />
</PopupTemplate>
</bp:DropDownButton>
<p Style-font-weight="{value: Bold ? 'bold' : 'normal'}"
Style-background-color="{value: Highlight ? 'gold' : 'transparent'}">Preview text</p>
using DotVVM.Framework.ViewModel;
namespace DotvvmWeb.Views.Docs.Controls.businesspack.DropDownButton.sample1
{
public class ViewModel : DotvvmViewModelBase
{
public bool Expanded { get; set; }
public bool Bold { get; set; }
public bool ColorsEnabled { get; set; } = true;
public bool Highlight { get; set; }
}
}
Properties
| Name | Type | Description | Notes | Default Value | |
|---|---|---|---|---|---|
| ClientIDMode | ClientIDMode | Gets or sets the client ID generation algorithm. |
attribute
static value
|
Static | |
| ContentTemplate | ITemplate | Gets or sets a template rendering contents of the control. |
inner element
static value
bindable
default
|
null | |
| 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. The DataContext is null in client-side templates. |
attribute
bindable
|
null | |
| Enabled | Boolean | Gets or sets a value indicating whether the button is enabled and can be clicked on. |
attribute
static value
bindable
|
True | |
| ID | String | Gets or sets the control client ID within its naming container. |
attribute
static value
bindable
|
null | |
| IncludeInPage | Boolean | Gets or sets whether the control is included in the DOM of the page. |
attribute
static value
bindable
|
True | |
| IsExpanded | Boolean | Gets or sets a value indicating whether the dropdown is open or not. |
attribute
static value
bindable
|
False | |
| PopupTemplate | ITemplate | Gets or sets the template used to render contents of the popup panel. |
inner element
static value
bindable
|
null | |
| Text | String | Gets or sets the text displayed on the button. |
attribute
static value
bindable
|
||
| ToggleIcon | IconBase | Gets or sets the toggle icon. |
inner element
static value
bindable
|
null | |
| Visible | Boolean |
attribute
bindable
|
True |