我试图在Android上的Google Maps InfoWindow中使用MvvmCross绑定。我有一个内置MapFragment的MvxFragment。 我为InfoWindow创建了一个自定义xml布局,并尝试使用MvxFrameControl来显示它,如下所示:
public class InfoWindow : Java.Lang.Object, GoogleMap.IInfoWindowAdapter
{
private readonly BaseStateFragment _window;
private readonly Dictionary<string, Restaurant> _restaurants;
public InfoWindow(BaseStateFragment window, Dictionary<string, Restaurant> restaurants)
{
_window = window;
_restaurants = restaurants;
}
public View GetInfoContents(Marker p0)
{
var layoutContainer = new MvxFrameControl(Resource.Layout.fragment_home_map_info, _window.Context, null)
{
LayoutParameters = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent),
DataContext = _restaurants[p0.Id] //ViewModel
};
return layoutContainer;
}
public View GetInfoWindow(Marker p0)
{
return null;
}
当我点击标记时,会调用方法GetInfoContents,但没有任何事情发生(事件绑定没问题,我让它无法绑定)。
有什么想法吗?
As Requested,布局文件:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<include
android:id="@+id/restaurant_item"
android:layout_width="310dp"
android:layout_height="190dp"
layout="@layout/item_list_restaurant" />
<Button
android:id="@+id/bt_open_restaurant"
android:layout_width="310dp"
android:layout_height="wrap_content"
android:text="@string/label_go_restaurant_page"
android:textColor="@color/colorFacebook"
android:background="@color/lightBlue"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:layout_gravity="bottom"
android:layout_marginTop="8dp"
android:textAllCaps="true"
android:layout_marginBottom="4dp" />
</FrameLayout>