Getting started with silverlight 3 mvvm - silverlight

I've just written my first silverlight 3 app.
It's written using the code behind in a rater messy way.
I want to refactor into mvvm.
I'm finding it extremely difficult to find any tutorials on this.
So far from what I can gather I'll probably need a mvvm framework.
Mvvm-light toolkit sounds like it might be what I want, but I can't find a beginners tutorial.
This is actually more frustrating than I thought - do I actually need a framework?
Would I maybe be better just trying to do this from scratch with out a framework?
How did you get started with silverlight and mvvm?
Also I'm using vs2008 so silverlight 4 is a non starter for me.
Thanks in advance for any pointers.

I recommend you start with my session at MIX 2010 "Understanding the MVVM pattern". I go into the MVVM pattern as well as two important components of MVVM Light Toolkit: RelayCommand and Messenger. This should give you a head start.
Then, check the articles on http://www.galasoft.ch/mvvm/getstarted#tutorials
For the records, I am working with a member of the community to produce documentation aimed at beginners, but it takes time, and we do it on our free time.
If you have questions, ask on StackOverflow, but please tag with mvvm-light. I am monitoring this tag and do my best to help people with samples when I can.
Cheers,
Laurent

Related

Looking for source codes of silverlight application that uses PRISM framework

I'm new in silverlight and prism framework and I want to explore some working silverlight applications that are based on prism.
As well as the included samples, there's an interesting set of articles here, complete with source code.
There's also some source at Elegant Code which I found useful, as well as a whole list of examples and tutorials at Patterns and Practices Guidance.
Also be aware that there are many alternatives to Prisim, and you could always write your own simple MVVM architecture if you were interested in learning more about it. For more information, Jeremy Likeness has a great article over at code project about the architecture, entitled MVVM Explained. I found this to be hugely helpful when developing my first Silverlight MVVM application.
Check out Prism hands-on labs and quickstarts (make sure to scroll to the bottom of the page):
Also, you may find this episode on Understanding the Value of Prism useful.

Learning WPF and MVVM - best approach for learning from scratch [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I've got about three years c# experience. I'd like to learn some WPF and the MVVM pattern.
There are a lot of links to articles on this site but I'm getting a little overwhelmed.
Would a sensible approach for a begginer to be forget mvvm for a while and just quickly learn a bit a of WPF, then come back to MVVM?
I had a leaf through Application=Code+Markup - Charles Petzold in work today, it doesn't seem to mention MVVM (at least not in the index). I was pretty surprised by this as I thought MVVM was supposed to be the "lingua franca" of WPF?
Also I've just started working at a new company and they are using MVVM with WinForms, has anyone come across this before?
Can anyone recommend a book that will teach me both WPF and MVVM?
It depends on your experience.
I personally felt that this was a lacking area in MVVM discussions, which was what led me to write my series on MVVM and WPF from a Windows Forms developer perspective.
I would not try to learn WPF without learning MVVM. You'll end up trying to "unlearn" many aspects, as WPF really doesn't make sense, completely, until you understand the separation of presentation and logic that's pervasive throughout the architecture. MVVM is really just extending this same separation into the application space.
As for "MVVM in Windows Forms" - a lot of people try to do this, but it's not really MVVM. In order to do "MVVM" you need access to a richer form of data binding than Windows Forms provides. "MVVM in Windows Forms" is really, typically, just Model-View-Presenter with a different name (riding the MVVM bandwagon, I'd guess), but not really the same as MVVM in WPF.
Jason Dolinger has an excellent video on the subject. It steps you through the process moving from using code behind files to a full MVVM pattern including Dependency Injection and Testing.
Bill Steele did a 16 part "Soup-to-Nuts" webcast series on WPF. The links on the msevents site are broken. Here is a Google search to find them. This will help with the WPF learning curve. And he does NOT use any MV* patterns in his examples.
EDIT: The MSEvents links are working now, I am leaving the Google search as a backup.
Josh Smith also has an excellent article WPF Apps With The Model-View-ViewModel Design Pattern on MSDN.
Herding Code:
Presentation Patterns with Jeremy Miller, Ward Bell, Rob Eisenberg and Glenn Block
Part 1
Part 2
MIX10:
Laurent Bugnion Understanding the
Model-View-ViewModel Pattern
Rob Eisenberg Build Your Own MVVM Framework
And of course Reed Copsey's MVVM articles are worth a read as well.
I was told a few times that my MIX10 session was explaining the MVVM pattern well enough for beginners (even though some parts are actually quite advanced, so don't worry if you need to re-watch certain parts).
The session is at http://live.visitmix.com/MIX10/Sessions/EX14
Sorry for the self-promotion.
Cheers,
Laurent
There aren't many books covering MVVM but there is one : Advanced MVVM
But there are lots of online resources and this one is a must read : WPF Apps With The Model-View-ViewModel Design Pattern
After that I suggest looking into frameworks like
MVVM Light Toolkit
Caliburn
To do big things (like learning WPF + MVVM) it is better to break the task in smaller steps.
I think that the best approach in this situation is to start by learning the UI part of Wpf. Learn XAML syntax, the layout system, the available controls and forget about binding and how to deliver data to the controls.
Once you know the UI basics of Wpf then it is time to move to MVVM. Learn how bindings work and the MVVM pattern.
In this Web you can find a tutorial focusing on the hands on but with the theory available:
http://www.learnmvvm.com
Here is a tutorial for MVVM http://www.codeproject.com/Articles/819294/Learn-WPF-MVVM-step-by-step-Basics-to-Advance-Leve which goes from basic to the advance level in 5 steps. So its like graduating from a 3 layer to full MVVM.
Try this site. It collects the various resources at one place.
http://learnandmasterwpf.blogspot.com/
I just read this book. It is not really about learning WPF, but it should be useful once you already know a bit of WPF and want to progress your understanding of MVVM.
http://www.amazon.co.uk/Pro-WPF-Silverlight-MVVM-Model-View-ViewModel/dp/1430231629

how start implement MVVM pattern

=======
So i decide to to develop my asp.net site into Silverlight.
I today start to search articles about MVVM pattern which i want use in my Silverlight app, and i am confused :/ It's hart to me understand how works this pattern. I am find 3 frameworks which supports MVVM pattern in Silverlight - Caliburn, MVVM Light Toolkit and GoodLight.
Should i start from own implementation of pattern or use framework?
Is this frameworks only a project solutions in which i can insert my code?
Which framework is the best for novice and which for professional?
I ask for this, cause i must start to rewrite my app from asp.net to Silverlight and i don't know that i can do it first and later (when i understand MVVM pattern and framework) implement this pattern in finished app ? Or from begining rewrite project to MVVM framework?
Going from ASP.NET to Silverlight is likely to require a (nearly) complete rewrite. The usage scenario is quite different. Silverlight is all about providing a client-side like development environment - it makes it so you can write an application the same way you'd write a client-side, desktop application, but execute this within the context of a browser.
This has fairly broad implications on how you'd use and develop your software.
That being said - for frameworks... Personally, I'd recommend getting a good grasp of MVVM first, then choose a framework (if any). MVVM is really a simple architectural design pattern. Once you understand it, the frameworks will make more sense. It's difficult to suggest "pick this framework", since they all add their own, valuable, additions and ways of working.
There are many good sources for learning about MVVM. Personally, (I'm being biased here), I like the intro I wrote (even if it's WPF oriented instead of SL oriented, the concepts are the same). That being said, Jerimiah Morrill's MVVM for Tards is also very good to get a basic understanding of what, exactly, it means when you say MVVM.
Once you understand this, the frameworks will be much more approachable (or avoidable, if you don't want them).

Is it ever too late to implement an architectural pattern such as MVC or MVVM?

I've been unleashed on version 2 of an application my company has been working on. It was our first foray into WPF and needless to say, a lot of lessons were learned. The product took a year to develop, so it's not a small application by any means. Everyone recently came on board with MVVM.
Now that we have a large code base with plenty of x:Name's and lots of logic in the code backing files, is it too late to switch to something like MVVM moving forward? Keep in mind, it's probably not in the budget to go back and change existing windows to adopt this pattern, so there will always be a mixture of both, should be adopt MVVM going forward.
Appreciate opinions on the matter.
I was in a similar situation. We started our WPF app when WPF was still in beta, and needless to say, we made a lot of mistakes in the early days. When we learned about MVVM it was clear that it was much better than our “MV” approach.
We already a fairly large existing code base and it was not realistic to stop what we were doing and convert to MVVM. We decided that all future development would use the MVVM pattern and we would gradually migrate the existing code base. Basically, whenever we needed to change an existing screen we took that opportunity to refactor and convert to MVVM.
That approach worked out well and today the entire project is using MVVM.

Do you know any real-world, useful WPF/Silverlight applications using MVVM?

I'm looking for code of full applications that (1) use the MVVM pattern and (2) are approachable for WPF/Silverlight/MVVM beginners. So far I have only found:
Crack.NET - A runtime debugging and scripting tool (useful but quite complicated)
CipherText - WPF Password Manager (perfect but written in VB.NET)
What are some others?
preferably smaller helper apps or tools that use MVVM but that have a completed feel, perhaps with WPF/Silverlight graphic/animation goodness, etc. which show not only the MVVM concepts being used but in a context of a real-world, completed application
My Contribution
Thanks for all the tips, I collected together a list of 15+ MVVM code examples and posted the here:
Overview of WPF/Silverlight code examples that help you learn MVVM.
I too class myself as a beginner in MVVM developing a large scale application for about a month now. I'm over most of the main hurdles, but keep getting confused up by a few things.
Be careful with the suggestions from Kent. They'll get you started, but the subtle differences in Silverlight and WPF will trip you up occasionally (triggers are one).
I don't know of any full sites, but I started with the Composite Application Guidance and PRISM libraries. These a little too cumbersome for a 'beginner' and just MVVM, but some of the concepts are very useful (event aggregator for example).
I suggest that you read blogs by Josh Twist, Josh Smith, Shaun Wildermuth and Nikhil Kothari. These guys are very knowledgeable. They are also very open to answering questions too.
What is your development background? Some of the concepts surrounding method calls, responses and delegation are a real break from "traditional sequential" coding techniques.
Given the question, you may be interested in the current effort going on to create a "Pet Shop" type reference implementation for M-V-VM. You can join the conversation or follow progress here.
I've been using MVVM for the last couple of months on a project and it's been fantastic. I've been doing UI work for over 12 years and it's the best thing I've come across.
I have been using MVVM for about 2 years now, and I can say that it is a resounding success. I have shipped one large-scale medical imaging solution using MVVM in Silverlight. I am also about to ship a complicated WPF application using Prism and MVVM extensively. In fact, I don't know how I'd achieve some of my problems elegantly without MVVM in this more recent application.
+1 on MVVM. It works. It is testable. It is extensible. It facilitates developer-designer workflows. It ALSO doesn't have to be messy and plumbing-heavy.
In addition, I created a medium-sized Silverlight application using MVVM for the CodeMash conference in January. You can see it and get the source code here.
Try this one. Also, Family.Show may be useful.
The WPF Disciples group has decided to create a real-world MVVM + Mediator reference application similar to the Pet Shop refence application for Web Apps. Your can follow the development on codeplex here

Resources