I am trying to bind a ListBox
from the View to a class in the ViewModel. I have no trouble binding it inside the main View. But when I try to do some binding in the other XAML views, I am getting the below error. What is the problem here?
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='OutlookCalendar.Controls.OpenSummaryLine', AncestorLevel='1''. BindingExpression:Path=SummaryLines; DataItem=null; target element is 'ListBox' (Name=''); target property is 'ItemsSource' (type 'IEnumerable')
<ListBox Grid.Row="6"
Grid.ColumnSpan="3"
Background="White"
Margin="5,0,22,5"
ItemsSource="{Binding SummaryLines,
RelativeSource={RelativeSource AncestorType={x:Type local:OpenSummaryLine}}}"
IsSynchronizedWithCurrentItem="True" />