私のviewmodelAでは、私のfragmentA.axmlのボタンをクリックすると、Mvxbindを行い、画面が変更され、viewmodelBが表示され、httpリクエストを送信するというプロパティがあります。期待どおりの応答を得る。これは私がそれが働く方法を正確に動作します。しかし、問題は、私は私のfragmentB.axmlページ(someNumberとステータス)でその応答を示すように見えることです。誰もこの問題で私を助けることができます。ありがとう!!MvvmCross - MvxBindは正しくバインドされていません
ViewmodelA.cs:
public MvxCommand SomeCommand
{
get
{
return new MvxCommand(() => something());
}
}
public async void something()
{
ShowViewModel<ViewModelB>();
SomeService serviceWrapper = new SomeService();
var model = {//Some Json request};
var result = await serviceWrapper.SubmitRequestAsync(model);
SomeResponse response = StaticMethods.DeserializeJson<SomeResponse>(result);
Status = response.SomeResponse1.Activity[0].Status.Description;
SomeNumber = response.SomeResponse1.SomeNumber;
Debug.WriteLine("SomeNumber : " + SomeNumber);
Debug.WriteLine("Status: " + Status);
}
private string _someNumber;
public string SomeNumber
{
get
{
return _someNumber;
}
set
{
SetProperty(ref _someNumber, value);
RaisePropertyChanged(() => SomeNumber);
}
}
private string _status;
public string Status
{
get
{
return _status;
}
set
{
SetProperty(ref _status, value);
RaisePropertyChanged(() => Status);
}
}
fragmentA.axml
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Submit"
android:id="@+id/Submit"
local:MvxBind="Click SomeCommand" />
fragmentB.axml
限り、私はあなたが行く見ることができるよう<TextView
android:text="Some Number:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/SomeNum"
local:MvxBind="Text SomeNumber "/>
<TextView
android:text="Status:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/status"
local:MvxBind="Text Status"/>
あなたのクラスは定義されていますか:INotifyPropertyChanged?あなたはクラス定義を提供していません –
私はちょっと混乱しています。ViewModelBにナビゲートしようとしているようですが、ビューに表示するプロパティはViewModelAにありますか? – Ulbo
@Ulboあなたが言っていることを見るが、ボタンをクリックするとhttpリクエストを送信したい。しかし、私の問題は、別のビューモデルのフラグメント(つまり、フラグメントB)にそのデータを表示する方法がわかりません。この問題にどう対処するか分かっている場合は、私に知らせてください。ありがとう –