essamce avatar image
0 Votes"
essamce asked DaisyTian-1203 commented

invoke all viewmodel propertychanged in MVVM

I have Wpf App implemented MVVM, and all viewmodels exists in One viewmodel called MainViewModel, so how to invoke PropertyChanged for all Properties in ALL viewmodels in the MainViewModel?
I know OnPropertyChanged(""); invokes all properties in a class, but i want it for whole project which exist in MainViewModel.

using .NetFramwork 4.7
thanks in advance, any help will be appreciated.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

since all viewmodels inherted from ViewModelBase i'm thinking of using reflection to call all properties in MainViwModel of type ViewModelBase and invoke OnPropertyChanged("");
but i don't know if this is a good idea in MVVM.

0 Votes 0 ·

I‘m a little confused by your description of the question, why do you want to invoke all the viewModel propertychanged? If the UpdateSourceTrigger value is UpdateSourceTrigger.PropertyChanged, then the value pointed to by the right arrow of TwoWay or the OneWayToSource bindings is updated as soon as the target property changes. Did you set UpdateSourceTrigger=PropertyChanged for the Binding in your UI?

0 Votes 0 ·

0 Answers