Skip to content

ListBox DisplayMemberPath doesn't work #213

@InflexCZE

Description

@InflexCZE

To Reproduce

<Window x:Class="LayoutTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:collections="clr-namespace:System.Collections;assembly=System.Runtime"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Window.Style>
        <Style TargetType="Window" BasedOn="{StaticResource {x:Type Window}}"/>
    </Window.Style>
    <Window.Resources>
        <x:Array x:Key="DataCollection" Type="collections:DictionaryEntry">
            <collections:DictionaryEntry Key="Name" Value="Alice" />
            <collections:DictionaryEntry Key="Age" Value="30" />
            <collections:DictionaryEntry Key="City" Value="London" />
        </x:Array>
    </Window.Resources>
    
        <ListBox
            DisplayMemberPath="Key"
            ItemsSource="{StaticResource DataCollection}"
            />

</Window>

Expected behavior
Image

Observed behavior
DisplayMemberPath is not respected. ToString is evaluated
https://source.dot.net/#System.Private.CoreLib/src/libraries/System.Private.CoreLib/src/System/Collections/DictionaryEntry.cs,83dec663d4204ba3,references
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions