2012-10-10 4 views
1

MVVMCross와 안드로이드가있는 mvxBindableListView에서 객체의 프라퍼티를 바인딩하려고 할 때 문제가 있습니다.안드로이드에서 mvxBindableListView에 프라퍼티 바인딩하기

클래스의 구조는 다음과 같습니다

public class A 
{ 
    public string MyPropertyA1 { get; set; } 
    public int MyPropertyA2 { get; set; } 
} 
public class B 
{ 
    public int MyPropertyB1 { get; set; } 
    public int MyPropertyB2 { get; set; } 
} 

public class C 
{ 
    public int MyPropertyC1 { get; set; } 
    public A MyPropertyA { get; set; } 
    public B MyPropertyB { get; set; } 
} 

mvxBindableListView 그런 식입니다 :

결과가
<?xml version="1.0" encoding="utf-8"?> 
<Mvx.mvxBindableListView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:local="http://schemas.android.com/apk/res/Android.Client" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
local:MvxBind="{'ItemsSource':{'Path':'Results'}}" 
local:MvxItemTemplate="@layout/detail_viewmodel" /> 

: 공공 ObservableCollection에 결과가 {얻을; 세트; 이 응용 프로그램을 실행할 때 변수 '결과'를 포함 요소의 수와 나에게 mvxBindableListView가 표시되면

<?xml version="1.0" encoding="utf-8"?> 
<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:local="http://schemas.android.com/apk/res/Android.Client" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="6dip" 
    android:layout_marginTop="6dip" 
    android:textAppearance="?android:attr/textAppearanceLarge" 
    local:MvxBind="{'Text':{'Path':'MyPropertyA.MyPropertyA1'}}" /> 

하지만 행은 비어} 과 detail_viewmodel입니다.

누구에게 무슨 일이 일어나고 있는지 알고 계십니까? 포함

public class Thing 
    { 
     public string Life { get; set; } 

     public Thing() 
     { 
      Life = Guid.NewGuid().ToString(); 
     } 
    } 

    public class SimpleEmail 
    { 
     public Thing MyThing { get; set; } 
     public string From { get; set; }  
     public string Header { get; set; }  
     public string Message { get; set; } 

     public SimpleEmail() 
     { 
      MyThing = new Thing(); 
     } 
    } 

그리고 템플릿 : 감사

답변

1

내가 포함 된 이메일을 사용하는 자습서 응용 프로그램을 변경하려고

<TextView 
android:id="@+id/email_header" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:layout_marginLeft="6dip" 
android:layout_marginTop="6dip" 
android:layout_toRightOf="@id/email_from" 
local:MvxBind="{'Text':{'Path':'MyThing.Life'}}" 
/> 

는 가이 드의 벌금을 보여 주었다.

코드를 보면 모델이 INotifyPropertyChanged를 지원하지 않기 때문에 바인딩하기 전에 ViewModel 속성을 설정하고 있는지 궁금합니다.

는이 문제를 해결하려면, 내가 시도 할 수 있습니다 : 앱이 다음 "TestValue"을 표시하는 경우

public class A 
{ 
    public string MyPropertyA1 { get; set; } 
    public int MyPropertyA2 { get; set; } 
} 
public class B 
{ 
    public int MyPropertyB1 { get; set; } 
    public int MyPropertyB2 { get; set; } 
} 

public class C 
{ 
    public int MyPropertyC1 { get; set; } 
    public A MyPropertyA { get; set; } 
    public B MyPropertyB { get; set; } 
    public C() 
    { 
     MyPropertyA = new A() { MyPropertyA1 = "TestValue" }; 
    } 
} 

당신은 작업 바인딩 것을 알고있다.

당신이 다음 오른쪽 값이 표시 얻을 필요가 있다면, 당신은 두 가지 선택이있다 :

  1. 당신이 바인딩 체인 INotifyPropertyChange 신호에 어딘가에서, 어떻게 든 데이터
  2. 에보기를 결합하기 전에 속성을 설정합니다 바인딩을 새로 고침해야한다는 것을 알 수 있도록 이벤트를 새로 고침해야합니다.
관련 문제