将属性从View绑定到ViewModel

时间:2017-04-27 20:33:27

标签: mvvmcross

我的自定义视图中有一个属性MyFunc

public class MyView : MvxLinearLayout
{
    public Func<Task<byte[]>> MyFunc { get; set; }
}

我想从ViewModel调用此函数。我如何绑定它以便我可以在我的ViewModel中使用它?

public class MyViewModel : MvxViewModel
{
    public Func<Task<byte[]>> MyFunc { get; set; } // Bind to it here so I can call it within this class
}

1 个答案:

答案 0 :(得分:0)

你不能以相反的方式工作。

源始终是ViewModel 目标始终是视图

我不知道你想用这个来实现什么。但是,您似乎希望使用图像或某种字节数据填充LinearLayout。

为此,请使用命令。如果您确实需要在共享代码中触发特定于平台的功能,则可以使用MvxInteraction。