1
Xamarin Forms 프로젝트에서 Realm 및 PropertyChanged Fody를 사용하고 있습니다. 두 모델 - Person
과 Friend
은 아래와 같습니다. person
개체에는 friend
개체에 대한 참조가 있습니다. person
의 Age
과 friend
을 두 개의 별도 레이블에 바인딩했습니다. 이제 PropertyChanged Fody
을 사용할 때마다 Age
이 변경되면 레이블을 업데이트해야합니다. 하지만 첫 번째 레이블 (사람의 나이) 만 업데이트되고 두 번째 레이블 (사람의 친구의 나이)은 업데이트되지 않습니다. 친구의 나이가 바뀌면 어떻게 알릴 수 있습니까?중첩 된 속성이 Realm 개체에 대한 알림을 변경했습니다.
[ImplementPropertyChanged]
public class Person : RealmObject
{
public string Name { get; set; }
public int Age { get; set; }
public Friend friend { get; set; }
}
[ImplementPropertyChanged]
public class Friend : RealmObject
{
public string Name { get; set; }
public int Age { get; set; }
}
이러한 것들을하기와 같이 Xaml에 결합시킨다. 영역이 내장 된 알림을 가지고 있기 때문에
<Label Text="{Binding person.Age}" />
<Label Text="{Binding person.friend.Age}" />