Visual Studio 2010 is super cool. Here are few features I love most in VS 2010.


Tip 1 - Generating Sequence Diagrams To Inspect And Document control flow

Another cool feature in Visual Studio 2010 is the ability to generate Sequence diagrams. You may right click inside a method and select “Generate the sequence diagram”  from the pop up menu, to generate the diagram. In this example, you may see that my SubmitOrder method in OrderViewModel class is instantiating an OrderServiceClient, to call AddOrderAsync method inside the same.


image 

Tip 2 - Architecture Explorer

A cool addition in VS2010 is the Architecture Explorer (Click View->Architecture Explorer). The Architecture Explorer will provide you a very friendly interface to browse through and navigate to your solution assets. You can right click on an item (Namespace, Class Name, or Class Member etc) and select ‘View Content’ to navigate to the definition as well.


image


Also, you can export the selected items to a graph document from the Architecture explorer. You can do this by selecting the members, and clicking the ‘Create new graph document’ button (in top left corner) of the Architecture Explorer. Let me export some of the members in my OrderViewModel class, and have a look at the generated graph. You can also use the graph document to understand your code members in a better way, to analyze circular references, un referenced nodes etc (see the image below.)


image


Tip 3 – Code Navigators

Visual Studio 2010 has a number of useful code navigators. A simple yet useful code navigation/identification feature is ‘Highlight Reference’ - you can double click on any member to view the references highlighted, and can navigate across references using the Ctrl + Shift + Up/Down arrows.
Another cool code navigator is the ‘Navigate To’ window. You can use ‘Navigate To’ to search code members quickly when you work with the editor.


image


You can bring up the “Navigate To” window using the shortcut Ctrl , (press Ctrl and comma). You can search by any term, and you can even search using camel case. See that I’m searching for ‘OV’, to get a list of all code members following the OV convention.


Another cool code navigation feature in Visual Studio 2010 is the ‘Call Hierarchy’ window. You may right click any member to bring up the popup menu, to select ‘Find All References’ to bring up the call hierarchy window. So, next time when you change a method, you can have a look at where all you are going to impact. You can also view all overrides of your method, if you have any.


image


Tip 4 – Pinning Data Tips While Debugging

When you are debugging, you can pin variable values, so that they’ll be there for you to see later.


image

Also, you can even enter comments for a pinned data tip, so that you can view the comment later.


image

VS 2010 has also got a tone of other Debugger Enhancements, read about them from Scott Gu’s blog if you are interested.


Tip 5 - Consume First Development

Visual Studio is so smart that it can stub your classes, members etc on the go, when you type the code. For example, assume that you have a customer class, and you thought it should have a new method while doing something. You can just type the member name (method, property etc), rest your mouse on top of the tiny blue line under your new method to bring up the popup menu.


image

Click that, and you’ll see VS stubbing the method for you, as shown below. Note that VS has inferred the parameter type.


image

You can do that with constructors, properties, method overloads etc as well. That is super cool, especially if you are a TDD guy.


Tip 6 – Extension Manager for downloading and installing plugins

The Extension Manager in Visual Studio 2010 will allow you to download and install cool plug-ins for your VS IDE. You can bring up the extension manager window by clicking Tools->Extension Manager. Extension Manager will connect to Visual Studio 2010 online Extension library, and you can search and find cool plug-ins there.


image

Once installed, you may also Disable or Uninstall your plug-ins from the extensions manager.  Happy Coding!!








Shout it
Read more >>

Here is a quick Windows Phone 7 client for Nerd Dinner. You can query the Nerd Dinner oData endpoint and see the dinners in the Bing maps as push pins. Also, you can select a Push Pin to view the related details of the dinner. Source code is available here

It is a spin off of my actual Silverlight + oData + Bing Maps Client for Nerd Dinner

It was a quick 1-2 hour work. Myself and Shoban was discussing this for some time, and today we spend some time together in Tech Ed India 2010 – and did a quick port - at least partially to Windows Phone 7.

 

image image  image

Key Changes from Silverlight Version

  • As you can’t add an oData service reference directly in VS 2010 Express for Windows Phone, we created an oData endpoint for Scott’s nerd dinner website (http://www.nerddinner.com) manually using the DataSvcUtil.exe from the command line, and added to the Phone project.
  • I’ve taken away the MEF (Managed Extensibility Framework) implementation (Yes, I know, Glenn block have a custom port of MEF to Windows Phone 7, but I’m not using that now :) )

Still some critical functionalities are missing, like you won’t be able to sign-in RSVPs, and you can’t initiate a call – But have a look at the source code to see oData, Bing Maps and Windows Phone 7 in action, and start adding functionalities by yourself ;).

Happy Coding.

  
Shout it
Read more >>

imageGuys, I’m talking at the Great Indian Developer Summit, April 20-23 2010; Indian Institute of Science, Bangalore, India.

image   

With over 6500 attendees benefiting over two game changing editions, GIDS is the gold standard for India's software developer ecosystem for gaining exposure to and evaluating new projects, tools, services, platforms,languages, software and standards.

My session will be : Hands on MVVM for WPF and Silverlight, April 20th. In this session, we’ll be exploring everything you need to know about creating useful, feature rich applications using WPF and Silverlight, leveraging the power of MVVM. My presentation will also cover binding concepts, Commanding, Behaviors (Triggers, Actions), User Controls etc.

Click here for details

The GIDS guys have created a nice poster (that you see on right) for my session. Cool :) Alright, so see you there!!

Shout it
Read more >>

I was thinking about creating a Blog digest, by picking few nice articles from this Blogimage. I finally did that over the weekend.

Silverlight:

WPF:

.NET 4.0 And C#:

C# Back To Basics

Frameworks:

Design Patterns

Neural Networks (these are a bit old)

 

Happy coding, Enjoy.

Shout it
Read more >>

After reading Scott’s post on creating an oData API for StackOverflow, I got inspired and was planning to book a long flight ticket to do some work with oData. Finally, over the weekend, I’ve decided to stay at home and create a quick browser in Silverlight for Nerd Dinner ;).

What we’ll be doing?

The Silverlight read only client can pull Dinners and RSVPs from Nerd Dinner website over the oData endpoint, and show them via the Bing maps control for Silverlight. I ended up putting the whole pieces together in less than two hours. You may also click a pushpin to view the dinner details. Wow, that was super easy. Have a look at the final app before we start, or see this video.

Now, let us have a look at how to build the above app. Download the source and keep it handy. Of course,you may do a lot of other exciting things as well – Creating a Windows Phone 7 client version of this, or creating a NetFlix oData client in Silverlight. 

Let us get back. In summary, this is what we’ll be doing now.

  1. Creating a Silverlight project
  2. See how to consume oData in Silverlight
  3. Use NerdDinner oData endpoint to pull Dinners and RSVPs from our Silverlight client
  4. Show them in a Bing map using Bing’s Silverlight Map SDK by geo-coding the addresses
  5. Enable our Silverlight application to run Out of Browser

We’ll be using the following technology stack. All these downloads are free for you.

Once you’ve the above pieces installed, you are good to explore the source code of Silverlight Nerd Dinner,or to roll out your own. So, here we go.

1- Creating a Silverlight Project

Create a new Visual C#->Silverlight Application Project in Visual Studio, and add the following references from the Add Reference dialog.

Note: You can add references to Bing maps control related libraries (Microsoft.Map.*) from C:\Program Files\Bing Maps Silverlight Control\V1\Libraries, if it is not available in the Add References dialog box

image 

2 – Consuming oData in Silverlight

If you are still wondering what is oData, you’ve definitely missed the Mix10K talks.

The Open Data Protocol (OData) is an open protocol for sharing data. It provides a way to break down data silos and increase the shared value of data by creating an ecosystem in which data consumers can interoperate with data producers in a way that is far more powerful than currently possible, enabling more applications to make sense of a broader set of data. Every producer and consumer of data that participates in this ecosystem increases its overall value.

Checkout the oData.org and oData FAQ if you want to learn more. Also, in this Mix 10 talks, Scott Hanselman explains how he and Jon Galloway created an oData end point to Nerddinner.com.

Consuming oData services in Silverlight is super easy. First of all, you need to add a service reference, pointing to your oData service. Right click on your Silverlight project in Project Explorer, and click Service Reference. Add a service reference to Nerd Dinner’s oData endpoint.

image

3 – Pulling Dinners and RSVPs

Once you have the service proxy created, the next step is pulling the Dinners and RSVPs. Most of this work is done in the NerdDinnerService.cs class. Here is an outline of our NerdDinnerServices class. Inside the QueryDinners method, we’ll query the service to pull the dinners in a specific date range.

image

Let us explore the QueryDinners method a bit further (image below). We are creating a new service context, and add a filter there to query the dinners between two given dates. oData supports various URI conventions and query options. For example, a $top query like http://nerddinner.com/Services/OData.svc/Dinners?$top=5 will return the top 5 dinners. If you want to order by a specific field (like EventDate), you can use the $orderby query, like http://nerddinner.com/Services/OData.svc/Dinners?$top=5&$orderby=EventDate

oData URI conventions are pretty simple. You can find a good reference here. In our case, we want to filter the dinners between a date range, so our query will look like  ?$filter=EventDate le datetime'2010-05-04T09:23:29' and EventDate gt datetime'2010-04-03T09:23:29'. In an oData query, a date time should be of the format datetime’yyyy-MM-ddThh:mm:ss’. GetODataFormat method will take a date to get us the correct format to create a filter. 

image

And if you are wondering what that Expand(“RSVPs”) is for, that’ll greedy load all the RSVPs associated with a given Dinner to that we’ll be having that information as well in our result. When we invoke BeginExecute, we should pass a callback (OnDinnerQueryComplete), so that our callback will be invoked once the query execution is done. And inside our OnDinnerQueryComplete, we call EndExecute to fetch the results as shown. Also, we raise the DinnersChanged event in our NerdDinnerService class, so that our view model can be notified.

image

Now that was pretty simple, isn’t it?

4 – Showing them in a Bing Map

So now, let us put together our view model and our view - so that we can display the dinners in a Map.

The ViewModel

Have a look at the NerdDinnerViewModel.cs, which is pretty minimal. The view model has We’ve a QueryDinners method which simply invokes the QueryDinners method in our data service. Also, you can see that we are using MEF for importing the services to our view model (see those Import(..) attributes). If you want to learn about MEF - you can always read my Introduction to Managed Extensibility Framework – Creating a Zoo and Animals

image 

When ever the DinnersChanged event is fired from the data service, we’ll trigger a property changed event, so that the View will rebind to the ‘Dinners’ property in our view model. The ‘Dinners’ property in our View Model is simple. We create a DinnerViewModel class for each Dinner, and return in. Have a look at DinnerViewModel.cs, it has a  has a Location property, projected from the Latitude and Longitude properties of a Dinner, for making our bindings easier. Also, we have the From and To properties in our ViewModel, to which the date pickers in our UI is bound to.

image

The View

Now comes the most interesting part, the XAML View of our client. Have a look at the MainPage.xaml. The crux of our view a Bing maps control, bound to our Dinners property. Get the Bing Maps key (as described above), and assign your own key to the CredentialsProvider property of the map.

image

Inside the resources section of the user control, we actually have a DinnerTemplate data template (which is set as the ItemTemplate of our Map control), to display each dinner as a PushPin. The DinnerTemplate decides how each dinner will get rendered in the map. For now, we’ll display the number of attendees as the header of each push pin. We’ll also show a small tooltip when the user hovers his mouse over the push pin. Also, note that we are binding the Pushpin’s Position property to the Location property of our DinnerViewModel.

image

When the user clicks a Pushpin, we’ll do the following things.

  • Show a Details Pane about the selected Dinner (See the DinnerView.xaml control)
  • Assign the selected Pushpin’s data context as the data context of the Details Pane
  • Zoom to the Address of the clicked Pushpin’s dinner.

Here is the relevant code from the DinnerPushPin_MouseLeftButtonDown handler in MainPage.xaml.cs.

image

If you are wondering what is searchHelper - The searchHelper is an instance of MapSearchHelper class (See MapSearchHelper.cs). Basically, the ExecuteSearch method will take an address, and find the corresponding lat and long values (address location) using Microsoft' Virtual Earth SearchService – and will zoom the map to the obtained location.

5 – Enabling our Application to Run out of the browser.

And finally, let us configure our application to run out of browser. To do this, right click your Silverlight project, and goto properties. Check “Enable running application out of browser”, and click “Out Of Browser” button. In the resultant dialog box (shown below), check ‘Require Elevated Trust’, and choose a Window Style you like.

image

Launch the Silverlight application.

Conclusion

Amazing. Integrating oData with Silverlight, and Bing maps was super easy. Let us launch the application. Right click and select ‘Install NerdDinner browser on this computer’. Search dinners, zoom to places, and click any RSVP button to join (it’ll just redirect to the social services using Scott’s actual NerdDinner site, in a new window).

image

And now, who want to take this up and build a Windows Mobile Phone 7 client for NerdDinner? It should be easy from here :). 

Don’t forget to read my other posts on Silverlight, C# etc. So, have a look at my recent Blog digest for more interesting stuff.

Shout it
Read more >>

imageThis post is a thank you note to Microsoft for awarding me the MVP status.

For the past few years, I’ve shifted my focus a bit more to client side technologies, like Silverlight and WPF. After joining Kerala Microsoft Users Group (k-mug.org) few years back, I used to give sessions via UG meetings, Microsoft Virtual Tech days etc. Today, I’m honored to be recognized as a Microsoft MVP for Client Application Development. Thank you Microsoft.

It is really good to be a part of the MVP community. First of all, you get access to a lot of great guys out there. Secondly, it is a great way to get early product releases and a lot of good content, insights and inspiration from Microsoft.

Looking back, it is (hopefully) interesting to see the kind of pots I’ve published in the last couple of months. Hence, I thought about creating a quick “.NET Journal Digest” – so that you can have a look at them in one place. This digest covers some of my hand picked Silverlight and WPF posts, along with few articles covering C# and .NET 4.0 features, Reactive Extensions, MEF etc

Read the blog digest here

Shout it
Read more >>

top