Getting started with MVVM in WPF

Hell lot of time passed since i updated my blog with a new post.  This time while working with WPF, i feel like write something on what is called MVVM Design pattern.

MVVM has got three components:

  • Model: Data+Classes; Nothing WPF sepcific.
  • View: This is the User Interface element visible to the user. Its DataContext is its ViewModel.
  • ViewModel: It contains all the data that needs to be displayed and procedures to modify the model at will. ViewModel knows nothing about the View.

This is very loosely coupled design pattern. The View knows the ViewModel but the ViewModel does not know the View. You can very easily replace the View without affecting the ViewModel. This is very useful in Developer/Designer teams where the Developer improves the ViewModel and the Designer enhances the View.

The fact that the ViewModel does not know anything about the View comes as a bit of surprise. A typical View in MVVM does not need have a code-behind (except for the general code that calls the InitializeComponent() method from the constructor)!!

You may be wondering how the view updates itself when the ViewModel changes and how it handles user interaction like button clicks etc. This is what makes MVVM specific to WPF.

The controls in the View bind themselves to the corresponding properties in the ViewModel. The changes in ViewModel will be reflected in the view, thanks to Data Binding in WPF. (Otherwise we would have had to handle every event and then update the view accordingly.)

As for user interaction, we always have had commands in WPF. MVVM leverages on this feature. Instead of writing event handling code for button clicks, we bind the buttons (or MenuItems) to Commands in the ViewModel. Every button binds itself to a command which the ViewModel exposes. This command delegates its job to a method in the ViewModel that gets the work done. But the problem is that there is no built-in command in WPF that does that. We have a RoutedCommand that targets UIElements but not methods. Here comes to the scene a new command that targets methods, the DelegateCommand or the RelayCommand. Controls can bind the RelayCommand (that the ViewModel exposes) and invoke methods in the ViewModel.

The DelegateCommand implements the ICommand interface and delegates the Execute and CanExecute methods in the interface to methods in the ViewModel.

That’s all with the theory and understanding i have. The sample code snippets i will update soon.

Aricent visit in my school

After a long span, i am writing my new post which is not techy in fact.
This is regarding my experience as a student coordinator on arrival of Aricent.
I had so many talks with the Aricent HR since the months of April-May and till now. But due to some reasons or other the things were not getting into shape. Finally, i somehow managed to invite it for recruitment in our campus on 13th Nov., 09. In the long run, the recruitment team arrived at our school in the morning at 09:00am. We had each and every sort of arrangements for that day. After a small talk, there started the pre-placement talk. Thereafter, there was a written exam (1 and half an hour) for which we sat and 14 qualified for the next round among 25. Then, there was a group discussion round for two teams of 7 students each. This was not an elimination round but the marks mattered in the last round that was interview, which lasted upto 7:30pm. Students were waiting for the results curiously. Finally, that time came when the HR announced 10 names of my friends who qualified for Aricent. I saw whole lot of crowd in a deep ocean of delight; but they didn’t know that the person who got immense pleasure from all that, was myself.
When this process was over, we made a warm see off with everyone in the team.

So, it was all about my experience..i hope it continues further.

Command line mp3 player in Linux

This post is after about a month long hibernation from my blog.
I made my mind up to listen songs as i usually do (it contributes to my hobby). In fact, i was suffering with a headburst headache, so i thought songs might be the stress buster and good entertainer too. What striked my mind was why couldn’t i play the tracks on command line rather playing’em in traditional RhythmBox or Amarok etc. The way i thought, the way i found…some googling let me find such a tool named mpg123, which is nothing but a command line player cum MPEG streamer.
Installation on Ubuntu/Debian: sudo apt-get install mpg123
Installation on RedHat/Fedora/Cent OS: For this, we have to first enable the rpmforge repo and try
yum install mpg123
and you are done.

Go to the shell; Move into your songs folder; and type in mpg123 * as below:
neeraj@nee-pc:/media/LEISURE/fun/songs$ mpg123 *
Just press Ctrl+C , if you want to switch onto the next song in the folder.
Have a glimpse of the mpg123 on my UbuntuBox:


Play files on the shell itself

Type man mpg123 and you will see what else can you do with this versatile thing.
Thanks GNU.

Movie of the week : Konchem Ishtam Konchem Kashtam

Konchem Ishtam Konchem Kashtam is a typical family entertainer which has been carved in the lines of Siddharth’s previous movie “Bommarillu”, but has a different concept of storyline.  I am not a kind of Kuchh Kuchh Hota hai like movie’s watcher but this movie has something worth watching. The feel of the movie is same as Bommarillu (the first ever South Indian Movie in Telugu, i watched), but the story, screenplay and the direction look different in an innovative way. This whole movie revolves around Siddharth and his love Tamannah and the kind of circumstances they face from their elders, after falling in love. After Vishal-Shekhar, it’s Shankar-Ehsaan-Loy composing for a Telugu movie. They don’t unleash their full potential here, but it’s still an enjoyable album. The song egire egire reminds me youth oriented songs in chartbusters such as RDB and Yuva.

A still is here:

egire egire from KIKK

egire egire from KIKK

A total of 7.5 is there from my side for this movie out of 10 which makes it My movie of the week!!

proftpd: A unique ftp server on my UbuntuBox

This was basically a novice step by me to setup an ftp server locally, but i succeed! Proftpd is the professional FTP daemon. It can be found in Synaptic package of Ubuntu or can be downloaded via apt-get. Just install it and use standalone server.

Launch it through console (see manual pages for documentation):

neeraj@nee-pc:~$ proftpd

and check through your browser whether it’s running or not. Type ftp://localhost/ in the address bar and assign username and password (the same you use to login into your system)there in the dialoguebox. You must see a window like this:

Local file transfer protocol
Local file transfer protocol

I tried to access it on other computer on my LAN through my ip:


and it was working perfectly fine. So..are you gaming to set up your own ftp?? what say??

The Google India Women In Engineering Award 2010

Hello Googlers!
I am pleased to inform you about The Google India Women In Engineering Award 2010‘. This is an initiative launched by Google India in 2007-2008 with an objective of recognizing and rewarding deserving women students in the field of Computer Science In this third edition of our awards, we welcome applications from female students pursuing Bachelors, Masters and PhD in computer science, who meet the eligibility criteria. Applications are open from15th Sept ’09 to 31st Oct ’09. A group of most deserving students will be chosen form the applicant pool and the award recipients will receive a sum of INR 100,000 each.Highlights of the last years awards can be found on the website.
Feel free to share this within your friends network.
For any questions, please write in to
I wish i would be from Venus! 🙂

Turned my Ubuntu’s desktop as Fedora’s!

I always had a willing to turn my desktop as fedora’s desktop. In my UbuntuBox, the desktop doesn’t show the computer’s icon, the Home folder or the trash. But now, all are there in one go. Have a look:

All icons

All icons

What say?? All you have to do is to install Ubuntu Tweak. Launch it from Applications-> System Tools-> Ubuntu Tweak.

Tweak your Ubuntu

Tweak your Ubuntu

Go under the tab Desktop->Icons and do whatever you want. That’s it! It has so many other features, explore as much as you can! Cool na! 🙂

LAMP installation on Ubuntu 9.04

Last night, i was thinking of configuring LAMP on my UbuntuBox. LAMP is an open source Web development platform that uses Linux as the operating system, Apache as the Web server, MySQL as the relational database management system and PHP as the object-oriented scripting language. (Sometimes Perl or Python is used instead of PHP.) Because the platform has four layers, LAMP is sometimes referred to as a LAMP stack. Stacks can be built on different operating systems. Developers that use these tools with a Windows operating system instead of Linux are said to be using WAMP; with a Macintosh system, MAMP; and with a Solaris system, SAMP.

I tried the following and got success:

Open terminal and typed:

neeraj@nee-pc:~$ sudo apt-get install lamp-server^

The total size downloaded was 43 mb approx and took about 20 minutes.
let us see, whether the installation succeeded??
open Firefox and type http://localhost/ . If the browser displays "It Works", means the installation is successful.

PHP test:

type in the terminal the following

neeraj@nee-pc:~$ sudo gedit /var/www/testphp.php

and type in the following code:


Save and close the file and restart Apache by:

neeraj@nee-pc:~$ sudo /etc/init.d/apache2 restart

Open the browser and put http://localhost/testphp.php in the addressbar, hit enter and if you see the following, php has been successfully installed.

php info
php info

Next is the turn of MySQL:

MySQL has to be bound with the localhost so type in the following to check whether the bind-address is

neeraj@nee-pc:~$ gksudo gedit /etc/mysql/my.cnf

I also installed phpMyAdmin which is optional:

open terminal and type

neeraj@nee-pc:~$ sudo apt-get install libapache2-mod-auth-mysql phpmyadmin

After this type in:

neeraj@nee-pc:~$ sudo ln -s /usr/share/phpmyadmin/ /var/www/phpmyadmin

type in http://localhost/phpMyAdmin in the addressbar of your browser and you get the following homepage:


Log in with the MySQL accoun and you are done. I forgot the password and hence tried the following:

sudo dpkg-reconfigure mysql-server-5.0

to reset the MySQL Password.

Now, everything’s peachy. 🙂

neeraj@nee-pc:~$ gksudo gedit /etc/mysql/my.cnf

Artha – Open Thesaurus

Although Ubuntu and several other Linux Distros provide it’s own dictionary which connects online to give you the results. Meanwhile i was thinking of something like Wordweb in windows. I found one mail regarding the same ..i managed somehow to install Artha on my works good..and i love it…

The open dictionary
The open dictionary