有人知道如何从 Xamarin.Forms 的 View 代码隐藏中将随机字符串值传递给 View 模型吗?
字符串值并非来自显示给用户的任何控件。
直到页面显示给用户之后,该值才可用。
我只能在 View 中使用该值,而不能在 View 模型中使用。
最佳答案
您可以通过 View
的 BindingContext
访问您的 ViewModel
来做到这一点,如下所示:
((ViewModelType)this.BindingContext).SomeProperty = "someRandomString"
关于c# - Xamarin.Forms - 将值从 View 传递到 ViewModel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44529781/