Windows Dev Center

Le sujet que vous avez demandé est indiqué ci-dessous. Toutefois, ce sujet ne figure pas dans la bibliothèque.

ItemsControl.DisplayMemberPath, propriété

Gets or sets a path to a value on the source object to serve as the visual representation of the object. This is a dependency property.

Espace de noms: System.Windows.Controls
Assembly : PresentationFramework (dans presentationframework.dll)
Espace de noms XML :

public string DisplayMemberPath { get; set; }
/** @property */
public String get_DisplayMemberPath ()

/** @property */
public void set_DisplayMemberPath (String value)

public function get DisplayMemberPath () : String

public function set DisplayMemberPath (value : String)

<object DisplayMemberPath="string" .../>

Valeur de la propriété

The path to a value on the source object. This can be any path, or an XPath such as "@Name". The default value is an empty string.

Identifier field


Metadata properties set to true


This property is a simple way to define a default template that describes how to display the data objects.

In the following example, the static resource named places is defined as a collection of Place objects, in which each Place object is consisted of a CityName property and a State property. The prefix src is mapped to the namespace where the data source Places is defined. The prefix scm and dat are mapped to the System.ComponentModel and System.Windows.Data namespaces respectively.

The following example creates a view of the data collection that is sorted by the city name and grouped by the state.


  <src:Places x:Key="places"/>

  <CollectionViewSource Source="{StaticResource places}" x:Key="cvs">
      <scm:SortDescription PropertyName="CityName"/>
      <dat:PropertyGroupDescription PropertyName="State"/>


The view can then be a binding source, as in the following example. Because of the specified DisplayMemberPath, eachPlace object is shown with their CityName value. If DisplayMemberPath was not specified and there is no DataTemplate, then the ListBox will display a string representation of each object in the underlying collection (in this case, "SDKSample.Place").

<ListBox ItemsSource="{Binding Source={StaticResource cvs}}"
         DisplayMemberPath="CityName" Name="lb">
    <x:Static Member="GroupStyle.Default"/>

To see the entire example, please see Collection View Source Sample.

Microsoft .NET Framework 3.0 est pris en charge sur Windows Vista, Microsoft Windows XP SP2 et Windows Server 2003 SP1.

.NET Framework

Prise en charge dans : 3.0

Ajouts de la communauté

© 2015 Microsoft