I have a class
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; }
}
data must be displayed in the following form

I do so - to link an MyData ListBox filled with data. For him, pointing DataTemplate, bring the code
<!-- 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>
How to Make Binding for lbData2? ListData1.ListData2 option does not work.
I believe that you can just use the following binding syntax:
ItemsSource="{Binding ListData1/ListData2}"
This means bind to the ListData2 property of current or selected instance of ListData1.
You can find out more from the Binding.Path Property page at MSDN.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With