Skip to main content

ComboBoxEdit.ValueMember Property

Specifies the path of the property to use as the actual value for the items in the control.

Namespace: DevExpress.XamarinForms.Editors

Assembly: DevExpress.XamarinForms.Editors.dll

NuGet Package: DevExpress.XamarinForms.Editors

Declaration

public string ValueMember { get; set; }

Property Value

Type Description
String

A string value that specifies a single property name of the bound data source, or a hierarchy of period-delimited property names that resolves to a property name of the final data-bound object.

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