2016-07-14 54 views
-4

我想在附加文件時添加說明,並使用MVVM模型。我創建一個commandHolder並從那裏創建一個命令,我無法將Lazy<View>轉換爲Lazy<RelayCommand>我請求你在這裏請幫助我。將Lazy懶惰<View>轉換爲Lazy <RelayCommand>並返回

this.fileAttachmentDescriptionCommandHolder = new Lazy<FileAttachmentDescriptionView>(() => new FileAttachmentDescriptionView { DataContext = this }); 

this.fileAttachmentDescriptionViewHolder = new Lazy<RelayCommand>(this.CreateFileAttachmentDescriptionCommand); 

我得到的錯誤:

Error CS0029 Cannot implicitly convert type 'System.Lazy Path.RelayCommand' to 'System.Lazy path.View'

+0

好像你正在給「commandHolder」分配一個視圖,並向「viewHolder」分配一個命令。這沒有多大意義。 – mechanic

+0

感謝技工和凱文 –

+0

@SanthoshRajoo可以自由地通過點擊投票按鈕下方的複選標記將答案標記爲「答案」,如果它確實回答了您的問題。 – Kcvin

回答

1

我覺得你倒着做的,如由技工評論說。

this.fileAttachmentDescriptionCommandHolder = 
    new Lazy<RelayCommand>(this.CreateFileAttachmentDescriptionCommand); 

this.fileAttachmentDescriptionViewHolder = 
    new Lazy<FileAttachmentDescriptionView>(
     () => new FileAttachmentDescriptionView { DataContext = this });