How to make following(please see the description) scenario generic

I came with some situation where I need to update only one property of class object(this is set using SetProperty method)

private ProfileSettings profileSettings;
public ProfileSettings ProfileSettings
{
get { return profileSettings; }
set { SetProperty(ref profileSettings, value); }//Used mvvmhelpers
}

here is my ProfileSettings class used for binding

public class ProfileSettings : BaseViewModel
{
   public string Country { get; set; } 
  //some other properties like timezone,dateformat etc...
}

Now when I click on country label in my ProfileSettingsPage it takes me to listview where I select particular country from list provided and when I comeback(Ondisappearing) I am passing this country item back to ProfileSettingPage using messaging center with selectedItem as parameter(TArgs).

Problem
If I don't make the Country bindable inside ProfileSettings class like below,it's not updating my label on page.

private string country;   
public string Country
{
  get { return country; }
  set { SetProperty(ref country, value); }
 }  

It's same for all other properties in my ProfileSettings class.

Questions:
1. How to know exactly which property to update.(Note: I need to also update particular item.child property of listview)
2. Better,how to make this generic so that it works on any viewmodel property and view type(xamarin forms ->label,datepicker etc...)

I also need to post this changes using this same object without assigning each and every property manually(I feel that should be the handled on Binding level automatically).

Please help me how to approach this as much generic as possible.

Sign In or Register to comment.