-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# DropdownField | ||
The DropdownField component is a control that allows users to select a single option from a dropdown list. | ||
|
||
## Usage | ||
DropdownField is included in the `UraniumUI.Material.Controls` namespace. You should add it to your XAML like this: | ||
|
||
```xml | ||
xmlns:material="http://schemas.enisn-projects.io/dotnet/maui/uraniumui/material" | ||
``` | ||
|
||
Then you can use it like this: | ||
|
||
```xml | ||
<material:DropdownField Title="Pick an option" ItemsSource="{Binding Items}" /> | ||
``` | ||
|
||
| Light (Android) | Dark (Windows) | | ||
| --- | --- | | ||
| ![MAUI Material DropdownField](../../../images/dropdownfield-light-android.gif) | ![MAUI Material DropdownField](../../../images/dropdownfield-dark-windows.gif) | | ||
|
||
|
||
## Icon | ||
DropdownFields support setting an icon on the left side of the control. You can set the icon by setting the `Icon` property. The icon can be any `ImageSource` object. FontImageSource is recommended as Icon since its color can be changed when focused. | ||
|
||
```xml | ||
<material:DropdownField | ||
Title="Pick an option" | ||
ItemsSource="{Binding Items}" | ||
Icon="{FontImageSource FontFamily=MaterialRegular, Glyph={x:Static m:MaterialRegular.Expand_circle_down}}" | ||
/> | ||
``` | ||
|
||
|
||
> [!TIP] | ||
> You can use any `ImageSource` object as Icon. But `FontImageSource` is recommended as it can change its color when focused. | ||
> Refer to the [Icons Documentation](../../../theming/Icons.md) for more details on using icons. | ||
|
||
## AllowClear | ||
DropdownFields support clearing the selected item by setting the `AllowClear` property to `true`. Default value is `true`. You can make it `false` to disable clearing. | ||
|
||
```xml | ||
<material:DropdownField | ||
Title="Pick an option (Clearable)" | ||
ItemsSource="{Binding Items}" | ||
AllowClear="True" /> | ||
|
||
<material:DropdownField | ||
Title="Pick an option (Unclearable)" | ||
ItemsSource="{Binding Items}" | ||
AllowClear="False" /> | ||
``` | ||
|
||
## Validation | ||
DropdownFields support validation rules. **SelectedItem**_(object)_ will be used to validate the control. You can set the `Validations` proeprty to add validation rules. Default | ||
|
||
```xml | ||
<material:DropdownField | ||
Title="Pick an option" | ||
ItemsSource="{Binding Items}" | ||
Icon="{FontImageSource FontFamily=MaterialRegular, Glyph={x:Static m:MaterialRegular.Expand_circle_down}}"> | ||
<material:DropdownField.Validations> | ||
<validation:RequiredValidation /> | ||
</material:DropdownField.Validations> | ||
</material:DropdownField> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters