I have a problem when I try to associate the "Enabled" property of my Android button with the logical element of my ViewModel using the MvvmCross structure, and I really don't know its origin.
So, I have a ViewModel that contains the following two properties:
private ProjectDetailDTO _projectDetail; public ProjectDetailDTO ProjectDetail { get { return this._projectDetail; } set { _projectDetail = value; RaisePropertyChanged(() => ProjectDetail); RaisePropertyChanged(() => HasPicture); } } private bool _hasPicture; public bool HasPicture { get { return ((this.ProjectDetail != null) && !String.IsNullOrEmpty(this.ProjectDetail.Pictures)); } set { _hasPicture = value; RaisePropertyChanged(() => HasPicture); } }
As you understand, my button is attached to the HasPicture property. Therefore, I have the following code for my button in my .axml file:
<Button local:MvxLang="Text LblSeePicturesValue" local:MvxBind="Enabled HasPicture,Click ShowProjectPicturesCommand" android:id="@+id/buttonPictures" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" />
I do not think this is a ViewModel problem because my WP application works well with this code. In fact, my ProjectDetailDTO is populated with a web service call, therefore using an asynchronous method. I think that when the binding implementation is implemented, the HasPicture property has a false value. But with my ViewModel code, the HasPicture property should be updated when ProjectDetailDTO is populated. Is there something I did wrong in my Android view?
Thanks for any help!
source share