Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ViewModel1 : ViewModelBase
- {
- private int _foo;
- public int Foo
- {
- get { return _foo; }
- set
- {
- if(value == _foo) return;
- _foo = value;
- OnPropertyChanged("Foo");
- OnPropertyChanged("Bar");
- }
- }
- public int Bar
- {
- get { return _foo * _foo; }
- }
- }
- public class ViewModel2 : ViewModelBase
- {
- public ViewModel2()
- {
- PropertyChanged += ViewModel2_PropertyChanged;
- }
- private void ViewModel2_PropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- if (e.PropertyName == "Foo")
- OnPropertyChanged("Bar");
- }
- private int _foo;
- public int Foo
- {
- get { return _foo; }
- set
- {
- if(value == _foo) return;
- _foo = value;
- OnPropertyChanged("Foo");
- }
- }
- public int Bar
- {
- get { return _foo * _foo; }
- }
- }
- public class ViewModel3 : ViewModelBase
- {
- private int _foo;
- public int Foo
- {
- get { return _foo; }
- set
- {
- if(value == _foo) return;
- _foo = value;
- OnPropertyChanged("Foo");
- UpdateBar();
- }
- }
- private int _bar;
- public int Bar
- {
- get { return _bar; }
- private set
- {
- if(value == _bar) return;
- _bar = value;
- OnPropertyChanged("Bar");
- }
- }
- private void UpdateBar()
- {
- Bar = _foo * _foo;
- }
- }
- public class ViewModel4 : ViewModelBase
- {
- public ViewModel4()
- {
- PropertyChanged += ViewModel4_PropertyChanged;
- }
- private void ViewModel4_PropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- if (e.PropertyName == "Foo")
- UpdateBar();
- }
- private int _foo;
- public int Foo
- {
- get { return _foo; }
- set
- {
- if(value == _foo) return;
- _foo = value;
- OnPropertyChanged("Foo");
- }
- }
- private int _bar;
- public int Bar
- {
- get { return _bar; }
- private set
- {
- if(value == _bar) return;
- _bar = value;
- OnPropertyChanged("Bar");
- }
- }
- private void UpdateBar()
- {
- Bar = _foo * _foo;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement