如何將CustomerRepository注入到CustomerVM視圖模型中?在我看來,一個WPF頁,我有:與WPF MVVM Unity,Generic Repository交錯
<Page.DataContext> <viewModel:CustomerVM/> </Page.DataContext>
但我的視圖模型構造顯然有參數傳入,
public CustomerVM(ICustomerRepository customerRepository) { //this._customerRepository = customerRepository; }
我得到
類型'CustomerVM'不可用作對象元素,因爲它不是 公共或未定義公共無參數構造函數或類型 轉換器。
真的很掙扎。
任何幫助表示讚賞。
你能給我們提供這個錯誤的靈嗎?或代碼片段? – Danpe
請參閱[這裏] [1] 我建議視圖模型定位方法 [1]:http://stackoverflow.com/questions/5830199/setting-viewmodels-property-from-xaml –