Friday, March 30, 2012

Windows 8 Developer Camp Update

I got a chance to visit Microsoft's office in Chevy Chase. MD, to attend the 2nd Windows 8 Developer Camp (in the country). And what a day it was. 


I started around 6:20 AM from my house in Mechanicsburg PA, planning to reach well before 8:30 AM, so that I could get a chance to meet the presenters in person. And also to network with other geeks. But the traffic at 270 S did hit me hard and I had to slow down. I reached around 9:10 AM... can you believe it?


Anyways, after getting a cup of (complimentary) coffee, I sat down to get the Windows 8 info into my brain.


There were two speakers - the famous Devhammer, none other than Mr. Andrew Duthie. And Frank. Frank La Vigne. They both are very enthusiastic and entertaining speakers. (Well, I got to sit near Frank when Andy was speaking and we had a nice discussion on Windows Phone and Windows 8.) Before starting on what topics were discussed, I would like to let all my geek friends know that I got to meet Jesse Liberty - yeah, the Jesse Liberty!!


Well, onto the topics of the day....


Windows 8 has two modes - Metro and Desktop. The Metro is the new mode which Microsoft has embraced as the new UI for its platforms. Metro UI is not stranger to Windows Phone fans. 


Windows 8 Platform




































As you see the above image  (boxography :)) of Windows 8 platforms, we have two kinds of apps - Metro style and  Desktop style. The new attention is to WinRT (Windows Runtime) library. WinRT is not a replacement of .NET. .NET still exists. It is used if you want to continue creating Desktop apps. The focus on the day was on Metro UI, and developing apps for Metro UI. And again and again, I heard Andrew Duthie speaking out that Metro is more geared towards Tablet kind of hardware. Mobile hardware, that is. Does that mean Desktop style apps would like as we have now? Seems so.


Andrew started talking about Contracts. Contracts are a new feature of sharing your app(s) with other apps. In fact, your app need not know about other apps. And other apps need not know about your app. If you feel that one (or more) of the feature in your app could be useful for other apps, then you could share that feature using Contracts. The type of Contracts:
  • Search Contracts
  • Share Contract
Search Contracts 
By using Search Contracts, you can make your app(s) listed when user searches for a specific keyword in the search charm. See below image for example. 














The user has searched on "Bing" keyword. All the apps displayed, have set up Search contracts with keyword "Bing".


Share Contracts 
You can make a part or a feature of your app share-able to other apps.


You can find more about Contracts here and here.

Snap Support
There is a feature in Windows 8 where in an app can be snapped (docked, that is) to one side, when you are working on another app. It's like Picture-in-Picture feature is some TVs. 


As you see above, the Stocks app is snapped on the left, while you are into other activities. You can define what kind of "view" of your app should be displayed when your app is "snapped". Cool eh?


Async
The async/await feature caught my attention. Using async/await feature, you could implement (code, that is) asynchronous calls as if you are coding synchronous ones. So cool. Code it to believe it. :)  The javascript equivalent of async/await is Promises. 


Content Vs. Chrome
They also stressed on concentrating on content than on chrome. It is so important that we should brainstorm on what content we need to deliver than on the design thingamajies (for lack of better word).  Thats the whole point of Metro. Content. Content. Content. Then a little chrome, if you may :)


WinRT
The beauty of WinRT is that there are no layers of libraries. No Win32 cover-ups.  No COM wrappers. Everything is baked into one plate - WinRT. Beauty!


Demos
Andrew Duthie was more of a HTML/Javascript guy, so he emphasized on HTML and Javascript are now a first class citizens on creating Windows 8 Metro apps. HTML-CSS3-Javascript gives compelling dynamics to create excellent apps, for sure. The demos were really great. 


Frank was more of a XAML/C# guy, and he showed some cool code in which we could leverage XAML and C# (also VB for that matter), in creating apps. This was more interesting to me, as I was already developing apps for Windows Phone and I could continue learning to producing apps for Windows 8 ecosystem.


Hands On


By 2:30 PM, we started with the hands-on lab. As I had already installed Windows 8 Consumer preview on Virtual Box and the Visual Studio 2011 Express Beta, I did not waste any time for it. I jumped on to hit the hands-on - the Recipes lab with XAML and C#. I had to stop in between as I had to start by 4 PM, to avoid the traffic.  Anyways, it was indeed a terrific day of infotainment. Thanks Frank and Andrew, for a wonderful day. And thanks Microsoft.


Stay tuned, for my Windows 8 Metro articles soon.

Friday, March 23, 2012

ListPicker

One of the finest controls in the Silverlight toolkit for Windows Phone 7, is the ListPicker control. But I had to struggle with it for a while. It was mainly because I didn't understand it quite well. Below you would find the 2 scenarios where I had to stumble:

1. SelectedItem should be set to a valid item.
That was the error I was getting no matter what I did to pacify the control. I googled (with Bing of course), and I found lot of ramblings on how buggy the control was and how this error never vanishes. This annoyed me. I gave up and wrote a query on Stackoverflow. The answers quite did not point the exact cause, but it gave me a direction to hunt. And there I was.... I had a property (which was of a reference type - in my case, instance of a Category class) in my ViewModel which bound to the SelectedItem of the ListPicker. But on that page, when I was loading the elements, I was trying to bind a "string" (CategoryName, in my case).


2. The selected item from the ListPicker does not get set when using FullMode. 
The difference between ExpansionAllowed and using a FullMode for displaying the ListPicker, is that after picking the item in FullMode, the page loads again. That is, any initializing that you might have executes. You need to preserve the selected item of ListPicker before you call the initializing and then reset the selected item once initializing is over.



Tuesday, March 13, 2012

TFS 2011 Express Beta download

I am a big proponent of using Source Control in our daily development. In my day job, we use Subversion. I had used TFS2010 earlier. It was the best source control/ALM software I had ever used. I should admit shamelessly that I don't have any source control for my Windows Phone development. You would think I am being modest. And some of you might ask why would I yearn for a source control when I am the only developer. That is a good point, but not a valid one.

Every developer should have source control. Period. No questions asked.

Then why would I not have one? Easy answer: Laziness!

I am at a point where I cannot more forward without having one. My colleague persuaded me to install Subversion. I also like it very much, as we had switched to it from being tired of VSS. I was all ready for it, when the news of TFS express version broke out. That caught my attention, and being an avid TFS fan, I decided to get it. The Beta is out and what was I waiting for.

Downloaded the TFS 2011 Express Beta from here.
It gives you two options: Web Install and ISO download. The web install is a trimmed down exe, which requires internet connection while installing TFS. ISO download is for if you need to burn to DVD and install it offline. I always prefer the ISO install.




The ISO file I downloaded had an issue - the SHA1 encryption did not match. So I had to download the web install. Again, I had an issue - my SQLServer Express was only SP1. It needed to be a SP2 or higher version. I downloaded that one too.

Then all the installation went smooth. There are lot of articles out there (Out There! Where? :) ) that explains the TFS 2011 express beta install step by step.

I opened up  VS2010 and connected to the TFS server I just created. I went on to create a new team project, but it cried out loud that I did not have permission to do so. (GRRRRR!!!!). That got me perplexed. I rechecked the security/group permission properties in TFS and all was all.

Back to Google with Bing!

After a while, I found that I needed VS2011 Team Explorer Express Beta to create a team project in TFS2011 Express Beta. Well, the error message was not that helpful - some copy/paste ignorance I think :)
(Read this: http://berxpert.wordpress.com/2012/03/02/connect-vs2010-to-tfs-11-express/)

Anyways, on to install the Team Explorer 2011 Express.

After creating the team project, I was able to connect to TFS and check in all my code through VS1010.

Whew!

All's well that ends  well.

I am on to gather all my WP7 projects and check them in. (And not to forget creating back ups).

Thursday, March 08, 2012

TwoWay binding issue while using ApplicationBar Icon

Just after my encounter with ApplicationBar Icons and RelayCommands, I faced another issue with two-way binding of a textbox. I had 3 textboxes in the page and 2 of them where binding properly. One of them was misbehaving. It was not misspelt (I checked that many times - I even rewrote the property and the binding element.) for sure. What could that be? After hours of head-scratching, I ventured into bing hunting! Google with Bing, as Scott Hansleman puts it.

It seems it is a problem with ApplicationBar button. No, not again!

OK, I have to be ready for it, it seems, as any elements in the ApplicatioBar is not a proper element. So don't expect a normal behavior. :)

So, the story is that binding would not work on the textbox on which the focus is on when pressing the button in the Application Bar. So, we have to manually (programmatically, I mean) bind it. Code Behind? Yes.

Laurent has a workaround in this article. It works (of course!), but it needs the textbox to be named. I found some other workaround while googling with bing.

And guess what, everything works like a charm. As they say, all's well that ends well! :)

Using AppBar Buttons with MVVMLight

On pondering over MVVMLight for a while, I decided to take it on for my new Windows Phone 7. It was very informative watching and reading Laurent Bugnion and Jesse Liberty's blogs and  videos. The one that helped me get started was The Full Stack series from Jesse, John Galoway and John Papa. Just search for "The Full Stack" in the Channel 9 web site.

I created an data entry screen, and a Save button in the Application Bar. On I went to create a RelayCommand to execute my method for saving the data. When I went to Blend, I couldn't drag-drop EventToCommand bahavior to the Save button. You should have seen me - just scratching my hair and looking confused. No, I wouldn't want you to see that face of mine anytime :)

What did I do wrong?

Well, I figured out that I was not doing anything wrong, but I was expecting a wrong thing. The EventToCommand could be used only with a FrameworkElement type. And ApplicationBar items are not. That made sense. So what do I do? How do I achieve this without writing code behind?

Well, as Laurent says in his blog, the MVVMLight cops are not going to catch me if I use code behind when using MVVMLight. So, on I went to write the code behind to execute my RelayCommand from my code behind! The only thing is that my dreams of not writing code behind has been shattered! Just Kidding!

Time to get back to my app. See Ya!

If any one is having trouble finding out a work around, and cannot solve the issue even after reading my blog, just email me - rajeevg[dot]nair[at]gmail.com. I will be glad to help you out.