c# - MVVM setting default values -
I'm sure this is a very common scenario, and I would like to know how MVVM developers deal with it.
I have a villa that is urgent on demand, and remains until it is clearly not removed by the user. This related view is loaded on the UI on demand. The view is capable of unloading and this visual model can still be present in the application.
In my scenario, I have a list box of preset colors in the view (setting it up to select an Xaml-defined supervisor of items to choose SolidColorBrush).
I have compiled the selectedItem property of ListBox for a property in ViewModel so that when the view is reloaded, the selected itam shows the last selected item in the list box correctly and when Also the user selects different colors, will handle VM changes.
My question is, how will u determine the set value, what will be seen when the first time the view is loaded, see the third item in the Observed Collection of Solid Collarbrushes?
I believe that the error of MVVM is in your implementation "separation of concerns "This makes your idea just an implementation, which, if needed / when it is switched or updated, once you put things in your thoughts, which is part of the application logic, then you should have maintenance headache The way is going down, and then the spaghetti code starts quickly Could.
Some people say, "Do not put any code in your thoughts", I agree 99% of the time. I say, "Do not put any domain / app / business logic in your view."
Whenever you are trying to put some code in your code, ask yourself, "If I switch from WPF to another framework, will my app still work?" If there is no answer, modify it to modify your viewold so that what you were trying to do in your view.
Comments
Post a Comment