Skip to main content
A newer version of this page is available. .

ComboBoxEdit.SelectedValue Property

Gets or sets the selected item’s value. Use the ValueMember property to specify the bound data source’s property that contains values.

Namespace: DevExpress.XamarinForms.Editors

Assembly: DevExpress.XamarinForms.Editors.dll

NuGet Package: DevExpress.XamarinForms.Editors

Declaration

public object SelectedValue { get; set; }

Property Value

Type Description
Object

An object that specifies 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. To obtain the selected item’s value, you can use the SelectedValue property.

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.

using System.Collections.Generic;
using System.ComponentModel;
using Xamarin.Forms;

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