SelectionView
SelectionView is a dynamic control. It needs a ItemsSource to generate views. It can handle single selections and multi selections.
Dark - Desktop | Light - Mobile |
---|---|
![]() |
![]() |
Supported Platforms
SelectionView isn't a platform specific control. It generates other controls dynamically. Please check control's supported platform that you're using with SelectionView.
Usage
Make sure you defined InputKit namespace in your XAML file.
MAUI | xmlns:input="clr-namespace:InputKit.Shared.Controls;assembly=InputKit.Maui" |
Xamarin Forms | xmlns:input="clr-namespace:Plugin.InputKit.Shared.Controls;assembly=Plugin.InputKit" |
SelectionView is designed to used with dynamic list of items. But still you can create a static list of items in XAML.
Basic Usage
- Basic usage is:
Regular Usage
In regular usage, you have to define items in a viewmodel.
Also, ComplexType items are supported too.
Tip:
ItemDisplayBinding
is not the only way to display item's name. You can overrideToString()
method of your item class to display custom name.
Data Binding
SelectionView Supports single and multi selections. Selections are defined in SelectionType
property. Some of selection types supports multiple selection and some them supports single selection. Default SelectionType is Button. Following selection types are supported:
Button
: (Default) Regular button selection. Only one item can be selected at a time.RadioButton
: Radio button selection. Only one item can be selected at a time.CheckBox
: Check box selection. Multiple items can be selected at a time.MultipleButton
: Multiple button selection. Multiple items can be selected at a time.SingleCheckbox
: Single checkbox selection. Only one item can be selected at a time.MultipleRadioButton
: Multiple radio button selection. Multiple items can be selected at a time. (But radiobuttons can't be unselected by their nature. This option isn't usuful much.)
Single selections can be handled with SelectedItem
or SelectedIndex
property.
Multiple selections can be handled with SelectedItems
or SelectedIndexes
property.
Customizations
SelectionView is a control that can be customized in many ways.
ColumnNumber
SelectionView can be divided into multiple columns. This property defines the number of columns. Default value is 2
.
You can easily make a segmented control by setting this property to 3.
IsDisabledPropertyName
SelectionView items can be disabled individually. This property defines the name of the property that is used to disable the control. Default value is IsDisabled
.
DisabledSource
Items also can be disabled from a a list of disabled item list source. This property defines the source of the list of disabled items. Objects should be same reference.
Otherwise;
- Item class should implement IEquatable interface.
- Item class should override
Equals
method inside and make manual check.
Overriding SelectionView Item
You can implement your own control and use it in SelectionView instead of using built-in SelectionTypes.
Firstly, you should create a new control that implements ISelection
interface.
Then you should override SelectionView's CreateItem()
method to return your control.
Use your component in XAML page.