|
| 1 | +--- |
| 2 | +uid: package-ui-controls-dropdownlist |
| 3 | +title: Using the DropDownList control |
| 4 | +--- |
| 5 | + |
| 6 | +# Using the DropDownList control |
| 7 | + |
| 8 | +The `MADE.UI.Controls.DropDownList` element is a custom-built UI element for Windows (UWP) applications that provides a selection user experience, allowing a user to select one or multiple items from a list. |
| 9 | + |
| 10 | +The control works in a similar way to the `ComboBox` element in the Windows SDK, with the added extensibility to change modes to select multiple items. |
| 11 | + |
| 12 | +Shown below is the visuals for the control in its default state, in a multiple selection mode. |
| 13 | + |
| 14 | +<img src="../../images/MultiSelectDropDownListCollapsed.png" alt="DropDownList control showing multiple selected items" /> |
| 15 | + |
| 16 | +<img src="../../images/MultiSelectDropDownListExpanded.png" alt="DropDownList control showing expanded selection with selected items" /> |
| 17 | + |
| 18 | +## Example usage |
| 19 | + |
| 20 | +```xml |
| 21 | +<Page |
| 22 | + x:Class="DropDownListSample.MainPage" |
| 23 | + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| 24 | + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 25 | + xmlns:controls="using:MADE.UI.Controls" |
| 26 | + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
| 27 | + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
| 28 | + Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" |
| 29 | + mc:Ignorable="d"> |
| 30 | + |
| 31 | + <RelativePanel Padding="12"> |
| 32 | + <controls:DropDownList |
| 33 | + x:Name="DropDownList" |
| 34 | + Header="MultiDropDownList" |
| 35 | + ItemsSource="{x:Bind ViewModel.ItemCollection}" |
| 36 | + RelativePanel.AlignLeftWithPanel="True" |
| 37 | + RelativePanel.AlignRightWithPanel="True" |
| 38 | + RelativePanel.AlignTopWithPanel="True" |
| 39 | + SelectionMode="Multiple" /> |
| 40 | + </RelativePanel> |
| 41 | +</Page> |
| 42 | +``` |
| 43 | + |
| 44 | +## Customizing the DropDownList |
| 45 | + |
| 46 | +The control has many customization properties that are exposed to tailor the experience for your application. |
| 47 | + |
| 48 | +### HeaderTemplate |
| 49 | + |
| 50 | +The `Header` can be customized to include custom UI elements as well as a string resource. |
| 51 | + |
| 52 | +The `HeaderTemplate` is also available to provide a `DataTemplate` for you to define the rendered UI for the `Header`. |
| 53 | + |
| 54 | +### ItemTemplate and ItemTemplateSelector |
| 55 | + |
| 56 | +The rendered UI elements for the items in the control can be customized with the `ItemTemplate` or `ItemTemplateSelector`. |
| 57 | + |
| 58 | +### SelectionMode |
| 59 | + |
| 60 | +The `DropDownList` has two selection modes, `Single` and `Multiple`. |
| 61 | + |
| 62 | +By default, the control works in a `Single` selection mode. |
| 63 | + |
| 64 | +### MaxDropDownHeight |
| 65 | + |
| 66 | +The height of the drop-down can be customized to allow you to show more results that the default expanded view. |
| 67 | + |
| 68 | +By default, the drop down will expand to 248 pixels. |
0 commit comments