Xamarin.android 绑定到当前绑定上下文?

Xamarin.android 绑定到当前绑定上下文?,xamarin.android,mvvmcross,Xamarin.android,Mvvmcross,我有一个项目模板,用于显示列表。为了做到这一点,我需要将ItemsSource绑定到当前绑定上下文,在WPF中,我会像{binding DataContext}那样在MvvmCross中如何做 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:local="http://sche

我有一个项目模板,用于显示
列表
。为了做到这一点,我需要将
ItemsSource
绑定到当前绑定上下文,在WPF中,我会像
{binding DataContext}
那样在MvvmCross中如何做

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res-auto"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
  <TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    local:MvxBind="Text Key"/> !**IGrouping.Key**!
  <Mvx.MvxLinearLayout
    android:id="@+id/items"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    local:MvxBind="ItemsSource DataContext" !**This doesn't work, should bind IGrouping as IEnumerable<string>**!
    local:MvxItemTemplate="@layout/item_myitem"/>
</LinearLayout>

!**I分组。键**!

您可以通过提供空路径绑定到当前源

为此,我发现最好的语法就是使用“”


然而,有些人更喜欢使用空字符串——尽管我觉得这有点不可读

<Mvx.MvxLinearLayout
   android:id="@+id/items"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="vertical"
   local:MvxBind="ItemsSource"
   local:MvxItemTemplate="@layout/item_myitem"/>

数据绑定文章中讨论了此选项以及更多选项-

(注意:空字符串绑定在nuget v3.0.9中被破坏,但应在v3.0.10中修复-请参阅)

<Mvx.MvxLinearLayout
   android:id="@+id/items"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="vertical"
   local:MvxBind="ItemsSource"
   local:MvxItemTemplate="@layout/item_myitem"/>