I'm using the MVVM pattern. In my ViewModel I have a public ObservableCollection:
public ObservableCollection<SettingsTemplateHistoryItemViewModel> HistoryItemCollection;
public SettingsTemplateViewModel()
{
this.HistoryItemCollection = new ObservableCollection<SettingsTemplateHistoryItemViewModel>();
}
In my View I have an ItemsControl with its ItemsSource property bound to the ObservableCollection in the ViewModel.
<ItemsControl ItemsSource="{Binding HistoryItemCollection}"/>
I'm getting the following error:
BindingExpression path error: 'HistoryItemCollection' property not found on 'object' ''SettingsTemplateViewModel' (HashCode=48413709)'. BindingExpression:Path=HistoryItemCollection; DataItem='SettingsTemplateViewModel' (HashCode=48413709); target element is 'ItemsControl' (Name=''); target property is 'ItemsSource' (type 'IEnumerable')
I'm baffled. I am 100% certain the property exists in the View's DataContext (i.e. the ViewModel). I've copied and pasted the property name into the View, so the binding path must be correct. The View and the ViewModel are wired up via implicit/typed DataTemplates. What am I missing?