私はXamarinとMvvmCrossでAndroidアプリケーションを作成しました。 いくつかのビュー(テキスト、編集テキスト、ボタン)をViewModelにバインドしたいとします。これまで何も変わったことはありません。しかし、私のバインディングは適用されません...私は型付きのFindViewByIdを使用すると、私はトレースエラーを取得しませんが、バインディングは適用されません。私は、アプリケーションを実行するとMvvmCross:空のバインディングターゲットがMvxTargetBindingFactoryRegistryに渡されました
、私は次のトレースがあります
MvxBind:Error: Empty binding target passed to MvxTargetBindingFactoryRegistry
MvxBind:Warning: Failed to create target binding for binding for TextProperty
OnCreate(Bundle bundle)
ボイドの私のオーバーライドは次のとおりです。
SetContentView(Resource.Layout.Reference);
var referenceTextView = FindViewById(Resource.Id.referenceEditView); // untyped FindViewById
var siteTextView = FindViewById<TextView>(Resource.Id.siteTextView); // typed FindViewById<T>
//var goButton = FindViewById<Button>(Resource.Id.goButton);
var bindingsSet = this.CreateBindingSet<ReferenceView, ReferenceViewModel>();
bindingsSet.Bind(referenceTextView).To(vm => vm.Reference).Mode(MvxBindingMode.TwoWay);
bindingsSet.Bind(siteTextView).To(vm => vm.Site);
//bindingsSet.Bind(goButton).To(vm => vm.GoCommand);
bindingsSet.Apply();
base.OnCreate(bundle);
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/siteTextView"
android:text="####"
local:MvxBind="Text Site"
android:gravity="center" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/referenceTextView"
android:hint="Numéro de dossier"
local:MvxBind="Text Reference" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Accéder"
android:id="@+id/goButton"
local:MvxBind="Click GoCommand" />
私のプロパティのgetterとsetterは、RaiseAndSetIfChangedメソッドを使用します。
private string _reference;
public string Reference
{
get { return _reference; }
set { this.RaiseAndSetIfChanged(ref _reference, value,() => Reference); }
}
私はLinkerPleaseInclude元のクラスと同じLinkerPleaseInclude
クラスをしました。 私の設定はMvxAndroidSetup
クラス から継承し、他のViewModelsではバインディングが正しく適用されます。私は、あなたが二回バインドする必要があると思うこれらの行を削除いけない
確かに、私はミスをしているかもしれません:私は知っているさまざまなアプローチを使用しました。 AXMLファイルで指定した行があります。 –
Androidの一般的な心配はありません。珍しいことがない限り、私はxamlのバインディングを行う傾向があります。 –