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
property icon ContentTemplate ITemplate Gets or sets a template rendering contents of the control.
attribute
inner element
static value
bindable
default
null
property icon Enabled Boolean Gets or sets a value indicating whether the button is enabled and can be clicked on.
attribute
inner element
static value
bindable
default
True
property icon IsExpanded Boolean Gets or sets a value indicating whether the dropdown is open or not.
attribute
inner element
static value
bindable
default
False
property icon PopupTemplate ITemplate Gets or sets the template used to render contents of the popup panel.
attribute
inner element
static value
bindable
default
null
property icon Text String Gets or sets the text displayed on the button.
attribute
inner element
static value
bindable
default
property icon ToggleIcon IconBase Gets or sets the toggle icon.
attribute
inner element
static value
bindable
default
null
property icon Visible Boolean
attribute
inner element
static value
bindable
default
True

HTML produced by the control