2016-07-14 20 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 });