我正在使用Listbox来呈现一个表格。 它使用DisplayMemberPath来显示项目。
如何进行多重绑定以显示项目?
假设我想显示ID和NAME ......是否有模板示例等?
日Thnx
答案 0 :(得分:9)
使用DataTemplate
。
<ListBox>
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}{0}, {1}">
<Binding Path="ID" />
<Binding Path="Name" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
答案 1 :(得分:2)
<ListView BorderThickness="1" ItemsSource="{Binding}" Margin="0,10,0,0" Height="Auto" Name="buyerDetailListView" Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
<ListView.View>
<GridView>
<GridView.Columns>
<GridViewColumn Width="50" Header="Serial" DisplayMemberBinding="{Binding Path=ID}" />
<GridViewColumn Width="100" Header="Date" DisplayMemberBinding="{Binding Name}" />
</GridView.Columns>
</GridView>
</ListView.View>
</ListView>