【发布时间】:2018-02-22 21:41:03
【问题描述】:
如果我有一个ListBox 并且它绑定到MyObject.MyCollection,我怎样才能获得MyObject.MyValue?
<ListBox ItemsSource="{Binding Path=MyObject.MyCollection}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Path=Name}"/>
<TextBlock Text="{Binding Path=MyObject.MyValue}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
public class MyObject {
public ObservableCollection<CollectionThing> MyCollection {get; set;}
public string MyValue {get; set;}
}
【问题讨论】: