Display properties of the ListBox.ItemsSource

隐身守侯 提交于 2019-11-27 16:14:22

You have two options.

The simplest method is to set the DisplayMemberPath property of your ListBox to "Title".

If you want to set not only what gets displayed, but the type of control that is used to display it, then you would set the ListBox's ItemTemplate.

For what your goal is, I would recommend the first option.

You can set a DataTemplate on the ItemTemplate property of the ListBox:

<ListBox ItemSource="{Binding}">
  <ListBox.ItemTemplate>
    <DataTemplate DataType="tfs:WorkItem">
      <StackPanel>
        <TextBlock Text="{Binding Title}" />
        <!-- Others -->
      </StackPanel>
    </DataTemplate>
  </ListBox.ItemTemplate>
</ListBox>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!