以下MarkerClick
实施工作正常,非常好。我可以通过ShowViewModel
View.cs
mMap.MarkerClick += MMap_MarkerClick;
private void MMap_MarkerClick(object sender, GoogleMap.MarkerClickEventArgs e)
{
ViewModel.MapInfoSelected(e.Marker.Title);
}
ViewModel.cs
public void MapInfoSelected(string name)
{
ShowViewModel<StudentViewModel>(new { studentName = name});
}
InfoWindowClick
不会触发打开其他视图。
View.cs
mMap.InfoWindowClick += MMap_InfoWindowClick;
private void MMap_InfoWindowClick(object sender, GoogleMap.InfoWindowClickEventArgs e)
{
ViewModel.MapInfoSelected(e.Marker.Title);
}
ViewModel.cs
public void MapInfoSelected(string name)
{
// it hits here, but does not hit `StudentViewModel` Init() method, the app is frozen and do nothing
ShowViewModel<StudentViewModel>(new { studentName = name});
}
我甚至尝试了SetOnInfoWindowClickListener
如下,它也没有打开视图。
mMap.SetOnInfoWindowClickListener(this);
public void OnInfoWindowClick(Marker marker)
{
ViewModel.MapInfoSelected(marker.Title);
}
更新
它甚至会点击OnPause()
方法,但如果我使用StudentViewModel
事件
InfoWindowClick
Init()方法
public override void OnPause()
{
base.OnPause();
mMap.InfoWindowClick -= MMap_InfoWindowClick;
}
答案 0 :(得分:0)
在onCreate
中,
将mViewModel.getLiveData().observe(this, new Observer<List<YOUR STUFF>>(){
放入.observe
中并将init()
方法放入,这对我来说是有效的