我有一堂课
public class MyData
{
public string Caption { get; set; }
public List<Data1> ListData1 {get; set;}
}
public class Data1
{
public string FirstName { get; set; }
public List<Data2> ListData2 { get; set; }
}
public class Data2
{
public string LastName { get; set; }
}
数据必须以下列形式显示
我这样做 - 链接一个 MyData ListBox 填充数据。给他,指点DataTemplate,带上代码
<!-- MyData -->
<Grid Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="{Binding Caption}" />
</Grid>
<!-- Data1 -->
<ListBox
Grid.Column="1"
DisplayMemberPath = "FirstName"
ItemsSource="{Binding ListData1 }" />
<!-- -->
<!-- Data2 -->
<ListBox x:Name="lbData2"
Grid.Column="2"
DisplayMemberPath = "LastName"
ItemsSource="{Binding ????}" />
</Grid>
</DataTemplate>
如何为 lbData2 进行绑定?ListData1.ListData2 选项不起作用。