将Lazy <view>转换为Lazy <relaycommand>并返回

时间:2016-07-14 11:38:22

标签: c# wpf mvvm

我正在尝试在附加文件时添加描述并使用MVVM模型。我创建了一个commandHolder并从那里创建了一个命令,我无法将Lazy<View>转换为Lazy<RelayCommand>我请求你帮助我。

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

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

我收到错误:

  

错误CS0029无法隐式转换类型&#39; System.Lazy   Path.RelayCommand&#39;到&#39; System.Lazy path.View&#39;

1 个答案:

答案 0 :(得分:1)

我认为你正在倒退,正如机械师的评论所述。

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

this.fileAttachmentDescriptionViewHolder = 
    new Lazy<FileAttachmentDescriptionView>(
        () => new FileAttachmentDescriptionView { DataContext = this });
相关问题