Note that there are some explanatory texts on larger screens.

plurals
  1. POI have some questions about MVVM pattern
    text
    copied!<p>My name is Jesús from Spain, I'm a .NET developer and I just discovered this great web few days ago.</p> <p>I have some questions about the MVVM pattern and I will be glad if you can answer them.<br /> I started using WPF three months ago and I've learned the MVP pattern.<br /> MVP is so good because you can structure the application so well.</p> <p>I started seeing MVVM everywhere, but everyone is using the pattern by his own method.<br /> Every blogger is talking about MVVM in their WPF's blogs but every implementation is distinct.</p> <p>I'm focused now with the implementations that use the MVVM toolkit on CodePlex, but I have questions and I can't find too much information.</p> <p>I think that MVVM is a variation of MVP.<br /> With MVP every view has a presenter that does the view's job.<br /> In MVVM it's the same thing but using commands whenever you can.</p> <p>I also saw that if you need an event, it's like with MVP; delegating the event to the presenter / View-Model, that is if it's not a job for the view (such as updating the UI).</p> <p>On the other hand, the View-Model doesn't has a View reference so I have to play harder with data-bindings.<br /> You have to use the DelegateCommands (that are the same thing as RelayCommands, right?).</p> <p>Uhm... more questions... Is it safe to use the same View-Model with two views / user-controls?</p> <p>Oh... I ran into a problem yesterday when I was playing MVVM.<br /> I created a <code>CommandReference</code> of my command for the key-binding thing and I assigned this reference to the command property of my button, well, the <code>CanExecuted</code> worked the first time but it didn't update the <code>IsEnabled</code> property when the <code>CanExecuted</code> was true. I fixed it by binding the command directly to the button and not using the reference. The question is: Why some code is linking the reference to the objects and why other code is binding the command directly?</p> <p>What things related with MVVM should I learn? (I saw something called attached behaviors yesterday but I don't know what is that).</p> <p>I'm rewriting a note tacking app that I developed using MVP but now with the MVVM. I will replace the events with commands (using the DelegateCommand), eliminate the views references on the View-Model and I think that's all because the examples that I saw of MVVM is much like MVP.</p> <p>Well, I will appreciate if you point me to all the misunderstandings that I have with this pattern.</p> <p>Thank you and in the future I will help the next MVVM novices :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload