background preloader

MVVM Light Toolkit

MVVM Light Toolkit

(WPFS) MVVM Light Toolkit: Soup To Nuts Part I While I’m not a zealot on the topic, I do believe that MVVM offers one of the best patterns for Windows Phone development and so, moving forward, the Windows Phone From Scratch series will incorporate MVVM in general, and the MVVM Light Toolkit in particular. I’m more than convinced that MVVM is an essential pattern for Windows Phone Development; and while there are many excellent frameworks to make MVVM development easier, the one I personally prefer to work with is the MVVM Light Toolkit and so it is the one I’ll focus on. I make the case for MVVM in this article, and so I won’t rehash that material here. Instructions for installing MVVM Light Toolkit are available here. I will not assume any background with MVVM or with the Toolkit beyond those two links. In that spirit, let’s begin by creating a two page MVVM application. Creating the Application To begin, open Visual Studio and click on New Project. Select MvvmLight and name the project MvvmLightNavigationBehaviorAndMessages. Hey!

Developer Review - Four ASP.NET MVC View Engines - Coding4Fun - Site Home - MSDN Blogs In this Developer Review, we evaluate four view engines available for use with ASP.NET MVC. First, we discuss the role a view engine plays in a website built with ASP.NET MVC, then we provide details about the four view engines in order to help you decide which one suits your needs. When we refer to a view engine in ASP.NET MVC, we are talking about three pieces of functionality: · A template locator/provider (implementation of IViewEngine) · A template that can render itself (implementation of IView) · A template engine that can parse and compile the view file syntax into executable code Combining these three pieces, a view engine provides your controllers with the ability to translate views into Html. Though the view engine that ships with ASP.NET MVC has all the functionality you need to create views for just about any website project, it is also easily replaced. As with choosing a programming language in .Net, there are many reasons why you may choose one view engine over another: Loops 1.

Windows Phone From Scratch #17: MVVM Light Toolkit Soup To Nuts Part 2 This is the second part of the MVVM Light Toollkit Soup To Nuts (part 1 is here) within the Windows Phone From Scratch Mini-tutorial series. Today we look at an introduction to behaviors as a tool for migrating event handling from code-behind to the View-Model. Behaviors were originally introduced in Blend to empower designers, but they turn out to be enormously helpful to C# programmers as well. What We’ll Build To illustrate this, we’ll return to the example we began in part 1, and extend it by adding a button to MainPage that will cause the application to navigate to page 2. First we’ll substitute a behavior for the event handler Second we’ll use messages (in part 3) to tell the page to navigate to the new page To get started, re-open MvvmLightNavigationBehaviorAndMessages in Expression Blend (if you don’t have the project, you can download the source code here.) Make the following changes to MainPage.xaml Click on Assets and then click on Behaviors. Leave the EventName as click.

Web Designers vs. Web Developers (Infographic) By Wix Let’s be honest. Being a web developer or a web designer doesn’t exactly give you an edge with the pretty girls (or guys) at your local pickup bar. If you were a part-time firefighter or investment banker, maybe. Nevertheless, the feud continues between web designers and web developers over which profession is the true calling. Like the yin and yang, these two are in constant battle to prove their dominance over the other, even when they work closely together. Here is an infographic of the differences between web designers and web developers. Click to enlarge.

Windows Phone From Scratch #18 – MVVM Light Toolkit Soup To Nuts 3 This is the third part of the MVVM Light Toollkit Soup To Nuts (part 1 is here) within the Windows Phone From Scratch Mini-tutorial series. Today we look at an introduction to messaging as a tool for communicating, e.g., from the view-model to the view. What We’ll Build To illustrate this, we’ll return to the example we began in part 1, and extended in part 2 (you can download the part 2 source code here). We stubbed out the handling of that command, but now it is time to complete the logic, by having the view model cause a navigation from MainPage to Page 2. There is and should be no visibility of a view from a view-model, however, and so we need a mechanism for sending out a message in a bottle to be picked up by anyone who is interested. Messaging Fortunately, the MVVM Light Toolkit provides extensive support for messaging. Begin by creating a new class in the project in Visual Studio, and call the new class GoToPageMessage. You’ll need to include the supporting library,

Explaining to your boss (or your wife:)) why tier based architecture doesn't scale Two weeks ago I had the pleasure of presenting at the NY JavaSIG. The event was hosted by an old friend, Frank Greco, who has been doing a really great work keeping the NY Java community up to date with the latest and greatest for quite some time (Great work Frank !). Even though it was one of those freezing NY evenings, the room was packed with around 300 people. In this presentation, I used an analogy that I refer to in many of my recent talks to explain the fundamental limitations of the tier-based approach. It goes like this: Imagine a Coca-Cola production line that consist of three factory lines: one producing the bottles, one filling them and the third shipping them. One day your manager says to you (you are responsible for the total production): "we’re going to launch a new campaign, we expect demand to grow to 10,000 bottles a day, how quickly can we be ready for this?". Coca-Cola Factory - "Tier Based" You are probably asking by now how all this is relate to computing?

Windows Phone From Scratch #19 – MVVM Light Toolkit Soup To Nuts #4 Let’s back up a bit and examine the day to day use of a View Model, and binding to the view model. In this mini-tutorial I’ll show the basics of binding a collection that sits in a View Model to a list box in the view. In the next, I’ll show how to capture the selection and, in the view model, determine what the details page should show. Let’s create a simple application that will display the full name of customers and their email, and that will (eventually) allow the user to click on one and go to the details about that customer. We start by creating a new MVVM application for Windows Phone. Creating the CustomerCollection The CustomerCollection class exists to give us some data to work with. Binding the ItemSource The key to understanding how MVVM handles the data binding is that the DataContext for the View is the View Model. When you set up the MVVM Light application the data context for this page was set to the view model, and there you’ll need a (read only) property for binding.

Passing Parameters With Behaviors In MVVM Light for Windows Phone Windows Phone From Scratch #20 MVVM Light Toolkit Soup To Nuts #5 In the previous posting in this series, we created a list of customers and we bound them to a list box. We did this not in the code-behind but in the View-Model. This forces the question of how we respond when a user makes a selection in the list box, if the logic for handling the selection is to be not in the view (the code-behind) but in the view-model. The answer will not be overly surprising to anyone who has been following this series; we’ll use a behavior to capture the selected value and pass the selection to the view model class. Taking this step by step, please re-open the project and create a new MVVMLight View named Details. Now, taking the lesson from Part 2, open MainViewModel.cs and add a property for the command (this will be bound to by the behavior) In the constructor initialize the RelayCommand: Note here that msg is the Customer being passed as a parameter from the behavior to the implementing method.

Related: