We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

MVVM Applied: From Silverlight to Windows Phone to Windows 8

00:00

Formal Metadata

Title
MVVM Applied: From Silverlight to Windows Phone to Windows 8
Title of Series
Number of Parts
110
Author
License
CC Attribution - NonCommercial - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this
Identifiers
Publisher
Release Date
Language

Content Metadata

Subject Area
Genre
Abstract
The Model-View-ViewModel pattern is a common denominator between applications using XAML to create the user interface. First applied in WPF, it was then easily ported to Silverlight and Windows Phone development. With WinRT and the Metro-style applications, XAML is now a first-class citizen for native Windows 8 development. Here too, the MVVM pattern is making developers' life easier, and proven components can be used to simplify and speed up application development. In this session, Laurent Bugnion, the creator of the acclaimed MVVM Light Toolkit, will present best practices around XAML-based Windows 8 application development, and how to leverage code and skills in Windows 8 too.
23
63
77
TwitterSoftware developerIdentity managementView (database)Data modelParity (mathematics)View (database)File viewerSoftware frameworkObject (grammar)Event horizonKeyboard shortcutBus (computing)Bookmark (World Wide Web)Different (Kate Ryan album)Power (physics)GodNatural numberCartesian coordinate systemUsabilityType theoryException handlingBitSource codeField (computer science)Similarity (geometry)Context awarenessEndliche ModelltheoriePoint (geometry)CodeExpressionGame controllerComputing platformState of matterConnected spaceNumberConfiguration spaceDirection (geometry)CASE <Informatik>Element (mathematics)Physical systemEnumerated typeData miningCategory of beingSystem callExecution unitWindowConnectivity (graph theory)Identity managementWeb pageDeclarative programmingTouchscreenMathematicsLevel (video gaming)Right angleRevision controlResultantInformationPattern languageMultiplication signTemplate (C++)Formal language19 (number)Video gameArithmetic meanSeries (mathematics)Flow separationDatabaseMultiplicationWritingMarkup languageFunctional (mathematics)ExergieWeb serviceObject-oriented programmingApplication service providerSurfaceService (economics)Computer animation
Transcript: English(auto-generated)
So, I guess it's time, right? Can you guys hear me okay? Yeah? Okay, so don't listen what he says. Listen what I say, okay? Cool. So welcome to the courageous who woke up in the morning.
We are going to talk about MVVM, and most especially, I think the purpose of this talk is really to tell you that there is no need to panic. I think that's really what I would like you to take back home. It's, you know, every time a new framework comes out, right, we hear all kinds of fearful comments
about the end of the world approaching. And what I would like to show you is really that Windows 8 is different from what we did before, Windows RT, but there are also so many similarities that every, basically, you know, when you start,
you feel at home quite fast, and then you discover the differences, and we have to work around those differences, and this is really what the talk is about. My name is Laurent Bunion, I work for IdentityMine. We are a user experience company. We work with different technologies,
though I would say our favorite is XAML. We are, IdentityMine was born from XAML, I would say, and it makes us really happy to see XAML used on a large number of platforms. We currently develop for, you know, Civilite WPF, obviously, but also more and more
for consumer-oriented applications, such on the Xbox, for example. We also do a lot of work with the Kinect. We work for Surface. We work for Windows Phone, et cetera. So it's really opening up, and XAML is running on a large number of platforms, and the interesting thing is that those principles
that we learned in WPF back then, and then since then in Civilite, et cetera, apply very well to all those worlds. For the small story, small anecdote, is that those applications that are developed for Xbox, Civilite is used there, so this is a version of Civilite,
which is used on the Xbox, and the MVVM Lite actually is used in many of those applications. So again, same principles apply. Whatever the screen is, whatever the size of the device is you can use that, which is a nice feeling. It's quite convenient.
So today I want to talk to you about MVVM, and let's start with a small recap so that we are all on the same page, right? So when we talk about those separation patterns in UI, we of course have to start with MVC because that's the most famous, that's where it all started. MVC is very old.
It was developed around 1984, back then with small talk. Who coded some small talk in his life? Nobody else? Wow. That was an interesting language, which was mostly developed, I think, for research purpose, but actually there are some applications which actually run in small talk,
and it was the first language where everything was an object, and when asked what is an object, the usual answer was, well, that's an object. So everything was an object, right? And this is really the very first fully object-oriented language. So, you know, MVC is very famous.
It's used everywhere. We have, of course, ASP.NET MVC. We have Ruby on Rails. It's also an MVC-based framework. And the idea here is that you have the models, the model being wherever your data comes from. It can be a collection of web services. It can be a database, et cetera. You have a view, which is what the user is seeing
and actuating and using, right? And then the controller is there to coordinate all that. So it's a little bit like the director for an orchestra. This is an object which is very powerful. So it goes a little bit into the concept of God object. It can do really a lot in your application.
Some would argue maybe a little bit too much. And, of course, this is an object that the application cannot live without. In XAML-based frameworks, the concept of controller is probably not the best, mostly because of the data binding system. So when we have data binding,
it makes sense to move to something else, which is the MVVM pattern. So here we again have the model, we again have the view. The main difference is that the controller is not a big controller for the application, but we have one small controller per view. Of course, your mileage may vary, so sometimes we have one view model for multiple views.
Sometimes we have views without view models, it depends. But basically, the idea being that you have this pair view view model. At the view model to model level, no big changes, same principles apply as before. So you have events, you have methods calls and all that. The big difference is really between the view
and the view model, where we use data binding. Data bindings are, the data binding system is very powerful. It also allows you to create those binding in a declarative manner, meaning that you don't write code for that, you write some markup. And there is a big advantage to writing markup,
first of all, because by nature, the data binding system is loosely coupled, which means that you can write at design time in your application a data template which is not placed in the context of any data context at all, and you can write your bindings. And then those bindings are going to be applied
when the application runs. That loose coupling has disadvantages too, right? It means that it is difficult to debug data binding because the data binding will never throw an exception when the data source is null, because this is loosely coupled, the nature of that.
The power of it is really this loose coupling, the fact that you can, in a very separate timeline, you can define your data objects and then later, another role, maybe even another person, can define how the UI is going to react to those data.
And also, data bindings are great for the tools. So we'll see examples with Blend later because markup is great for the tools. Of course, data bindings work well there too. Now sometimes the view needs to communicate to the view model in a more elaborate way, in a more advanced way than just with data bindings. And for that, we like to use commands.
Commands are a way to expose a method, to expose a functionality as a property and then we can use data binding to bind, for example, a button or a UI element to those commands. And then in the other direction, sometimes again, the view model needs to communicate with the view in a more elaborate way than with data bindings.
For example, if you need to start and coordinate animations in a precise way, then you probably need to do something in the view. And in that case, I'm going to show you how to use something called view services to do that. Another way would be to use a messenger of some type, a type of event bus.
And you have different ways to do that. So we'll talk about that. When you do that, when you go from the view model to the view, one component which is nice to use is the behavior. Behaviors are very powerful. They are a way to encapsulate a piece of view code
and then to reuse it later in your application. It's very convenient, it's very two-label as well, so it's very bindable. The nice way, very blendable, I mean, sorry. The nice thing is that you communicate with your behaviors with data binding.
So again, you have this advantage of this loose coupling between your view model and your view. Imagine that you have a property on the view model which is true or false, or maybe an enumeration. And then in your view, you want to control animations based on that. Well, you can do that with a behavior and the view model doesn't have to worry
about what's going to happen in the view, okay? So it's very nice. It's also very blendable. Behaviors are very easy to drag and drop and configure in Expression Blend, which is, of course, an advantage because it means that a non-technical person, such as a designer, for example, can do the work.
Now, behaviors have a big disadvantage. It's that they don't exist on Windows 8. So in Windows 8, we need to find workarounds. Let me say yet at this point, they don't exist yet. I think that everybody agrees that they are very, very useful. And who knows?
I think at some point in the future, we might see them, but I don't have information on when that may happen. So right now, we have to use work.