3
votes

I have a list of user with property like Id, UserName, FirstName and LastName.

How will i set the combobox' Display to show "LastName, FirstName" so on the combobox it will show like "Doe, John".

1

1 Answers

7
votes

You can use ItemTemplate to display any arbitrary property on your model object on the UI (as for this example, Firstname and Lastnames):

<local:ComboBox.ItemTemplate>
    <DataTemplate>
        <StackPanel Margin="0,3,0,3">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Path=Firstname}" />
                <TextBlock Text="{Binding Path=Lastname}" />
            </StackPanel>
        </StackPanel>
    </DataTemplate>
</local:ComboBox.ItemTemplate>