像这样提供的Publisher
类,或者无论你怎么称呼它,使用具有一个索引公开征集财产公开作者:
<ListBox x:Name="listBox" ItemsSource="{Binding Publishers}" .... />
<TextBlock Text="{Binding SelectedItem.Authors[0].Name, ElementName=listBox}" Grid.Column="1" Grid.Row="0"></TextBlock>
这将显示第一作者的名字指数0
如果要显示所选发行的所有作者,你应该使用一个ItemsControl
:
<ItemsControl ItemsSource="{Binding SelectedItem.Authors, ElementName=listBox}"
Grid.Column="1" Grid.Row="0">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"></TextBlock>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
来源
2017-07-04 09:57:36
mm8
,如果你有一个项目集合使用ListView和作为的ItemSource在你的视图模型设定对象的ObservableCollection(publlishers?),然后作为ItemTemplate中设置你的textbblocks – miechooy