Xceed Toolkit for Maui v2.0 Documentation
DisplayMemberPath Property (ComboBox)
Example 


Xceed.Maui.Toolkit Assembly > Xceed.Maui.Toolkit Namespace > ComboBox Class : DisplayMemberPath Property
Gets or sets a path pointing to a value within the source object in order to provide a visual representation of said object. 
Syntax
'Declaration
 
Public Property DisplayMemberPath As String
'Usage
 
Dim instance As ComboBox
Dim value As String
 
instance.DisplayMemberPath = value
 
value = instance.DisplayMemberPath
public string DisplayMemberPath {get; set;}
Remarks

To understand how this works, imagine that the ItemsSource is a list of persons with various informations divided into different properties, like Names, Surname, Age, etc., all contained within a Persons object. The DisplayMemberPath property could be set to target the Name property held within the Persons object so that the ComboBox displays the names of the persons listed in said Persons object.

Note that this property cannot be used if the ItemTemplate property is also used; it is only possible to use either the ItemTemplate or the DisplayMemberPath property at any given time. 

Example

In the following example, the ItemsSource uses a binding on the UserObjects property of the ContentPage, which is a collection of objects representing various persons.

Each object, meaning each person in the collection, has various attributes stored in properties, like Name, Surname, Age, etc.; as their names suggest, those properties contain various informations about each person in the collection.

Here, the DisplayMemberPath is used to retrieve the data found in the Name property so that the ComboBox can display the names of the persons in the collection.

<xctk:ComboBox WidthRequest="125"
               ItemsSource="{Binding UserObjects, Source={x:Reference _contentPage}}"
               DisplayMemberPath="Name"/>
Requirements

Target Platforms: Windows 11, Windows 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

ComboBox Class
ComboBox Members