I am new to MVVM template, so please bear with me. I have seen incarnations in wpf + mvvm + prism, where all views tend to have IView as the topmost interface. Then the views in the respective modules have a view-specific interface, for example IViewA, IViewB, etc., which implement the IView interface. Even the viewmodel has the largest IViewModel interface, and subsequent modules have IViewAViewModel, IViewBViewModel, etc., which inherit from IViewmodel. IViewmodel has a link to Iview, and Iview has a link to IViewModel.
namespace xxx.xxx.infrastructure { public interface IView { IViewModel ViewModel {get;set;} } public interface IViewModel { IView View {get;set;} } public abstract class ViewModelBase : IViewModel, INotifyPropertyChanged { public IView View {get;set;} public ViewModelBase(IView view) { View = view; View.ViewModel = this; }
I have a few questions.
1.) Is this a violation of MVVM, since the code behind the file must have zero code?
2.) In the view model, the MVVM should not worry about the view or its contract? Does this implementation violate the above?
3.) I do not understand what the use of this implementation is. This actually borders on MVP and requires a lot of code.
4.) If this is an acceptable implementation method, I need to have interfaces for all types and viewing modes in all my modules.?
source share