I'm learning MVVM.
I have my View filling two comboboxes from ObservableCollection properties in my ViewModel (eg. properties "Oc1" & "Oc2"). I also have a property bound to the selected item of Oc1 (eg. property "SelVal") that Oc2 depends on, so when property SelVal is changed, Oc2 needs to re-get it's data from the database.
Now, I've come up with a solution and it works for my situation but doesn't seem to adhere to the principle of a get accessor so I'd like to know what problem might I face down the track and what is a better solution?
My current solution is:
The get accessor of Oc2 queries the database and sets it's private field to the value returned from the database (which the View uses). So when SetVal is changed, I simply call this.RaisePropertyChanged("Oc2") in the SetVal set accessor and the View asks for Oc2, which in turn queries the database and returns the updated list. The problem is that I'm not using the get accessor for what it is meant for, as I'm assigning it's value in it. But what I like about it is it's self-contained (ie. I don't need a "BindOc2" method which I'd have to call in the constructor and then again in the SelVal set accessor). Please advise. And what's a better way?