私はMVVMパターンを使用しています。私のViewModelには、パブリックなObservableCollectionがあります:
public ObservableCollection<SettingsTemplateHistoryItemViewModel> HistoryItemCollection;
public SettingsTemplateViewModel()
{
this.HistoryItemCollection = new ObservableCollection<SettingsTemplateHistoryItemViewModel>();
}
私のビューには、ViewModel の ObservableCollection にバインドされた ItemsSource プロパティを持つ ItemsControl があります。
<ItemsControl ItemsSource="{Binding HistoryItemCollection}"/>
次のエラーが表示されます。
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')
私は困惑しています。プロパティがビューの DataContext (つまり、ViewModel) に存在することは 100% 確信しています。プロパティ名をコピーしてビューに貼り付けたので、バインディング パスは正しいはずです。View と ViewModel は、暗黙的/型指定された DataTemplates を介して接続されます。私は何が欠けていますか?