Reputation: 201
I have a ViewModel that is bound to one page called SettingsView. In this page i have some properties like so:
public string SettingsHeaderTitle { get { return AppResources.settings_header_title; } }
I have one button that navigates to another page where we can change language and then goes back to SettingsPage. I had implemented a command like so:
public void UpdateView()
{
RaisePropertyChanged(string.Empty);
}
My problem is that when I call this command from on Loadedd or NavigatedTo events nothing happens. Then I added a button to call this command (for debug purposes) and the Page is updated successfully.
What am I doing wrong?
Upvotes: 1
Views: 6354
Reputation: 1804
You need to implement INotifyPropertyChanged
on your ViewModels like so
public class SelectionItem<T> : INotifyPropertyChanged
{
private AppliesTo _appliesTo;
public AppliesTo AppliesTo
{
get { return _appliesTo; }
set
{
_appliesTo = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("AppliesTo"));
}
}
}
EDIT: I just noticed you're using MVVM Light, then it becomes even easier, in your ViewModels inherit from ViewModelBase
and make your property like this:
private bool _isComparisonRun;
public bool IsComparisonRun
{
get { return _isComparisonRun; }
set
{
if (_isComparisonRun == value) return;
_isComparisonRun = value;
RaisePropertyChanged(() => IsComparisonRun);
}
}
Upvotes: 1