There are 2 classes. One is a parent that contain a list of the second class as a property. The second class has a list also.
The problem is the application doesn't bind the list inside the second class.
The application will display a list of grid that bind from the second class list (in the parent class) and each grid will display information from the list inside the second class.
Now each grid doesn't bind value
Class Parent{
public List<NestedClass> Child { get; set; }
.
.
.
}
Class NestedClass{
public ObservableCollection<SomeParameter> Params{ get; set; }
public string Name
{
get
{
return "Hello world";
}
}
.
.
.
}
The xaml as below.
<ItemsControl HorizontalContentAlignment="Stretch" ItemsSource ="{Binding Child}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<ItemsControl ItemsSource="{Binding Child.Params}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="80"/>
<ColumnDefinition Width="80"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<TextBlock Text="{Binding Count}" />
</Grid>
<Grid Grid.Column="1"></Grid>
<Grid Grid.Column="2"></Grid>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
The output window show as below
System.Windows.Data Error: 40 : BindingExpression path error: 'Params' property not found on 'object' ''NestedClass' (HashCode=16626097)'. BindingExpression:Path=Params; DataItem='NestedClass' (HashCode=16626097); target element is 'ItemsControl' (Name=''); target property is 'ItemsSource' (type 'IEnumerable')
Edited#1 Added the xaml
Edited#2 Added the output message
Edited#3 Added the name property in the NestedClass