Introduction to MVVM pattern in WPF

The Model View ViewModel (MVVM) is an architectural pattern used in software engineering that originated from Microsoft as a specialization of the Presentation Model design pattern introduced by Martin Fowler. Largely based on the Model-view-controller pattern (MVC), MVVM is targeted at modern UI development platforms (Windows Presentation Foundation and Silverlight) in which there is a UX developer who has different requirements than a more “traditional” developer (i.e. oriented toward business logic and back end development).

Model
The Model is defined as in MVC; it is the data or business logic, completely UI independent, that stores the state and does the processing of the problem domain. The Model is written in code or is represented by pure data encoded in relational tables or XML.

View
A View is defined in XAML and should not have any logic in the code-behind. It binds to the view-model by only using data binding.
In simple examples, the View is data bound directly to the Model. Parts of the Model are simply displayed in the view by one-way data binding. Other parts of the model can be edited by directly binding controls two-way to the data.

ViewModel
The term means “Model of a View”, and can be thought of as abstraction of the view, but it also provides a specialization of the Model that the View can use for data-binding. In this latter role the ViewModel contains data-transformers that convert Model types into View types, and it contains Commands the View can use to interact with the Model.
The ViewModel exposes public properties, commands, and abstractions. The ViewModel has been likened to a conceptual state of the data as opposed to the real state of the data in the Model.

References
Wikepedia
Tales from the Smart Client
Model-View-ViewModel Pattern

kick it on DotNetKicks.com

Shout it

pimp it

Experience Space using Microsoft WorldWide Telescope

We already have been visualizing the earth on our desktops for quite a long time now. Thanks Google Earth and Bind maps.

Ever wondered if we could visualize space this way as well? Imagine taking a close look at a stars or galaxies like Milky way right from your desktop? Or even taking a view of Moon or Mars? Well Microsoft Research has come up with a solution to this.

Microsoft Research WorldWide Telescope

Yes that’s true we have a software from Microsoft which will soon be integrated into Bing maps and it enables us to view space with the help of images captured by telescopes all around the world.

What is WWT
The WorldWide Telescope (WWT) is a Web 2.0 visualization software environment that enables your computer to function as a virtual telescope—bringing together imagery from the best ground and space-based telescopes in the world for a seamless exploration of the universe.

Choose from a growing number of guided tours of the sky by astronomers and educators from some of the most famous observatories and planetariums in the country. Feel free at any time to pause the tour, explore on your own (with multiple information sources for objects at your fingertips), and rejoin the tour where you left off. Join Harvard Astronomer Alyssa Goodman on a journey showing how dust in the Milky Way Galaxy condenses into stars and planets. Take a tour with University of Chicago Cosmologist Mike Gladders two billion years into the past to see a gravitational lens bending the light from galaxies allowing you to see billions more years into the past.

Some of the Tours available at the website are as follows:
Search for Extra Solar Planets
Apollo Missions 15 to 17
Pluto
Aug 1, 2008 Eclipse
Orion Nebula – Hubble’s
The Ring Nebula
Beautiful Nebulas
Center of the Milky Way
Universal Beauty
Impact with M31
and many more….

So what are you waiting for? just visit the website and enjoy looking at stars even during day time 🙂

kick it on DotNetKicks.com

Shout it

pimp it

Nullable Type in C#

Nullable type in C#
We can declare a variable as nullable when we want to know that a value has been assigned to that variable or not. Declaring a variable as nullable enables the HasValue and Value members. We can use the HasValue property on the variable to check if the value has been assigned to the variable.

Example of Using Nullable
Let’s take an example of boolean variable. As we know the default value for a boolean variable is false. But we want that we should be able to know if user has selected true or false. So we define the bool variable as nullable like this:

Nullable<bool> testVariable= null;

Now we have the testVariable as a boolean variable having a value of null. Now when use the properties like this :

if(testVariable.HasValue)
MessageBox.Show(String.Format("Value is {0}",testVariable.value )); 

kick it on DotNetKicks.com

Shout it

pimp it