关闭ViewModel时,Xamarin形成MVVMCROSS如何传递参数
我使用MVVMCROSS有Xamarin形式。我的视图模型之一加载了一个新的ViewModel:
public class ViewModelMainForm: BaseViewModel, IMvxViewModel<string>
{
..... some code here .....
public void Prepare(String parameters)
{
// should get incidentId HERE****
}
public async void OnShowIncidentForm()
{
var result = await _navigation.Navigate(typeof(ViewModelIncidentForm), _selectedItem.EmployeeId);
}
}
然后,新视图看起来很完美,我可以在准备
方法中接收员工。
public class ViewModelIncidentForm : BaseViewModel, IMvxViewModel<string>
{
..... some code here .....
public void Prepare(String parameters)
{
employeeId = parameters.ToString();
GetEmployeeData(employeeId);
}
public void CloseView(int incidentId)
{
_navigation.Close(this, incidentId);
}
}
所有这些都可以完美,问题在于,当我关闭视图模型以弹出到上一个ViewModel时,我不知道如何获取参数“ InventiDID
>”。
在我的主要形式ViewModel中,我已经在准备方法中放置了一个断点,但没有触发。
关于如何在我的主ViewModel中使用navigation.close()
方法中发送的参数的任何线索?
I have a Xamarin Forms using MVVMCross. One of my view models loads a new ViewModel like this:
public class ViewModelMainForm: BaseViewModel, IMvxViewModel<string>
{
..... some code here .....
public void Prepare(String parameters)
{
// should get incidentId HERE****
}
public async void OnShowIncidentForm()
{
var result = await _navigation.Navigate(typeof(ViewModelIncidentForm), _selectedItem.EmployeeId);
}
}
Then the new view appears perfect and I can receive the EmployeeId in the Prepare
method.
public class ViewModelIncidentForm : BaseViewModel, IMvxViewModel<string>
{
..... some code here .....
public void Prepare(String parameters)
{
employeeId = parameters.ToString();
GetEmployeeData(employeeId);
}
public void CloseView(int incidentId)
{
_navigation.Close(this, incidentId);
}
}
All this works perfect, the problem is that when I close the ViewModel to pop to the previous ViewModel I don't know how to get the parameter "incidentId
".
In my main form ViewModel, I already placed a breakpoint into the Prepare method but is not triggered.
Any clue on how to get the parameter sent in the navigation.Close()
method in my main ViewModel?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论