开发者

Silverlight: how to set combobox DisplayMemberPath with multiple properties from a list

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".


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜