Say I have this ViewModel and xaml:
class MyViewModel
{
public MyStringValue {get;set;} = "HelloWorld"
public IList<CustomObject> ChildViewModels{get;set;}
}
<DataTemplate DataType="{x:Type local:MyViewModel}">
<ItemsControl ItemsSource="{Binding ChildViewModels}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<TextBlock Text="{Binding Path=MyStringValue,
RelativeSource={RelativeSource Mode=FindAncestor,
AncestorType={x:Type local:MyViewModel}}}"/>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
I keep getting this error message: "Cannot find source for binding with reference 'RelativeSource FindAncestor ... " So basically, I'm trying to bind the parents property container of ItemsControl and it seems like I can't.