2017-02-17 2 views
0

現在、MvvmCrossを使用してXamarin.Androidアプリケーションを作成しようとしています。2つのプロパティを持つMvxAutoCompleteTextViewバインディング

これは私が達成しようとしているものです:

Multiline autocomplete

これはその背後だAXMLされています

<android.support.design.widget.TextInputLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="8dp" 
    android:layout_marginBottom="8dp"> 
    <MvvmCross.Binding.Droid.Views.MvxAutoCompleteTextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:hint="Klant naam" 
     local:MvxBind="Text Klant.Naam; ItemsSource KlantNamen; PartialText CurrentKlantHint; SelectedObject SelectedKlant" /> 
</android.support.design.widget.TextInputLayout> 

私は名前と番号を含むリストを使用したい

答えて

1

MvxAutoCompleteTextViewにItemテンプレートを指定する必要があります。

<MvvmCross.Binding.Droid.Views.MvxAutoCompleteTextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:hint="Klant naam" 
     local:MvxItemTemplate="@layout/my_template" 
     local:MvxBind="Text Klant.Naam; ItemsSource KlantNamen; PartialText CurrentKlantHint; SelectedObject SelectedKlant" /> 

my_templateの中には、提案されたアイテムごとに独自のレイアウトを定義します。そのテンプレート内のビューを、KlantNamenコレクション内のViewModelsのプロパティにバインドします。魔法のように

<?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:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="55dp" 
    android:paddingLeft="?android:attr/listPreferredItemPaddingLeft" 
    android:paddingStart="?android:attr/listPreferredItemPaddingStart" 
    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" 
    android:paddingRight="?android:attr/listPreferredItemPaddingRight" 
    android:background="?attr/selectableItemBackground"> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="30dp" 
     android:textAppearance="@style/TextAppearance.AppCompat.Title" 
     local:MvxBind="Text Name" /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="25dp" 
     android:textAppearance="@style/TextAppearance.AppCompat.Subhead" 
     local:MvxBind="Text Price" /> 
</LinearLayout> 
+0

作品:

これはのようになります!ありがとう –

関連する問題