Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Is it common to store "non-model" classes (maybe helper classes) that I don't wanna use in a ViewModel inside Model directory in MVVM project?
For example:
Models\SongModel
Models\ID3TagReader
ViewModels\SongViewModel
If no, how should I encapsulate these classes?
In this design, the views know of the ViewModel and bind to its data, to be able to reflect any changes in it. The ViewModel has no reference to the views—it holds only a reference to the model.
For the views, the ViewModel acts both as a façade to the model, but also as a way to share state between views (selectedContacts in the example). In addition, the ViewModel often exposes commands that the views can bind to and trigger.
refer to the link..
http://blogs.msdn.com/b/ivo_manolov/archive/2012/03/17/10284665.aspx
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I'm a beginner with wpf app building and entity framework.
I'm building my first wpf app, I found out I should have replaced my auto-generated ICollection with ObservableCollection.
The problem is that I already did most of my code so far but am having some issues with INotifyPropertyChanged. I see all the codes about INotifyPropertyChanged use ObservableCollection.
Is it bad if I go to my auto-generated code now and replace the ICollection with ObservableCollection? Will it mess up my app?
ObservableCollection is only useful if you want to add items to a collection at some point, and have a UI control automatically update to display the added / deleted items. ObservableCollection also has potential threading issues - any change to the collection must be done on the same thread as it was created on.
It has nothing to do with reflecting changes to properties of individual elements within the collection - that is what INotifyPropertyChanged is for.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
In this tutorial INotifyPropertyChanged is in Model - not in ViewModel.
Is it correct and acceptable? What are standards ?
INotifyPropertyChanged is just an interface that provides functionality, it's not MVVM specific in any way. Classes generated by Linq to SQL or the like also usually implement it for example.
It is correct! You should raise PropertyChanged where you change the property (so in the model in your case). In other cases it might be in the view model but it can really be anywhere.
I think the confusion starts because the properties in the view model must raise the PropertyChanged event to update the UI. That does however not mean that the PropertyChanged event must have its origin in the view model.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I'm new to WPF and MVVM pattern. I've been reading about it and I come to a little doubt.
I'll build an WPF application that mainly does access to a database (oracle), but this access is done by an WebService (DataService). My question is in the Model part.
Should I create a class to each table on the database, on my Model, or should I just use the entities that the service provides me?
My guess is use the entities of the service, and then just do the CRUD operations in my application. But I want your opinion.
Thanks in advance.
It is always a good practice to use your own Models. That way, if the Service changes the structure, you will only need to change one point (where you map the item to your own entity), else you would have to change your whole application
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I know my question is subjective and context dependent, but being a beginner to MVVM, I came to know that generally one of the MVVM class is made singleton. Can anybody please tell me if I have Model, ViewModel and View class, generally people prefer which class as singleton and why is it so?
Technically, the Application class is really the only "required singleton" in a WPF application, and that's mainly because WPF will create it for you.
Otherwise, I typically avoid singletons in my WPF applications completely - there is no reason to introduce them.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have two features: one that presents the details of a single entity (EntityX) and one that allows the user to view a list of all EntityXs.
Using MVP, is it better to have an EntityXController with two methods (View and List, for example) that use the appropriate View and List views, or should I comply with my interpretation of the SRP and create an EntityXListController and an EntityXViewController to narrow the responsibilities of each?
That sounds more like same Model, different View-Presenter for Details, and another View-Presenter for List.