Skip to main content

ComboBoxEdit.SelectedValue Property

Gets or sets the selected item’s value. Use the ComboBoxEdit.ValueMember inherited property to specify the bound data source’s property that contains values. This is a bindable property.

Namespace: DevExpress.Maui.Editors

Assembly: DevExpress.Maui.Editors.dll

NuGet Package: DevExpress.Maui.Editors

Declaration

public object SelectedValue { get; set; }

Property Value

Type Description
System.Object

The selected item’s value.

Remarks

You can bind the ItemsSource property to a collection of custom objects. Use the DisplayMember and ValueMember properties to specify the names of data source fields that contain captions for items in the drop-down list and their values. Use the ValueMember field values to define the SelectedValue property.

You can also use the ComboBoxEdit.SelectedItem property to specify the selected item by the data source object. To set the selected item by its index, use the ComboBoxEdit.SelectedIndex property.

If the ValueMember property is not set, the SelectedValue property returns a data object as the SelectedItem property.

Handle the SelectionChanged event or use the SelectionChangedCommand property to respond user selection actions.

Example

The code below shows how to bind a ComboBoxEdit to a list of business objects. A Person object exposes the Name, Age, and Location data fields. The DisplayMember property is set to Name, and the ValueMember is set to Age. As a result, the editor shows persons’ names in the drop-down list but the SelectedValue property returns the selected person’s age.

DevExpress MAUI ComboBox - Display Member

using System.Collections.Generic;
using System.ComponentModel;
using Microsoft.Maui.Controls;

namespace ComboBoxExample {
    public partial class MainPage : ContentPage {
        public MainPage() {
            InitializeComponent();
            this.BindingContext = new List<Person>() {
                new Person {Name = "Devin", Age = 50, Location = "Atlanta"},
                new Person {Name = "Brenda", Age = 25, Location = "Memphis"},
                new Person {Name = "Sean", Age = 36, Location = "Houston"}
            };
        }
    }

    public class Person {
        public string Name { get; set; }
        public int Age { get; set; }
        public string Location { get; set; }
    }
}
<dxe:ComboBoxEdit ItemsSource="{Binding}"
                  DisplayMember="Name"
                  ValueMember="Age"/>
See Also