Monday, November 23, 2009

Silverlight 4 : A long term player

Well, I still not came out of those glorious demos of Silverlight 4 Beta shown by Scott Gu on eve of PDC09..My mind is still in that 2nd Day keynote at PDC..Wow !! Microsoft and Team Silverlight made it !!

Silverlight_Logo

You all must be wondering why this place is still silent despite Silverlight 4 Beta announced 2-3 days back, Nothing like that. I am already getting ready to give you lot of good stuff over next couple of weeks.I do blog about Silverlight with demos which I feel that you can use in your day to day business apps. Last time while Silverlight 3 Beta was announced, I wrote full series of articles. This time I am planning to put more concepts than code, Offcourse working code will be there in article, but main discussion will be around the actual practical application of features introduced in Silverlight 4.

Till the time I start filling my Silverlight 4 Beta articles here, A good thing will be to download environment and get ready to see the future !

A good place to visit : http://silverlight.net/getstarted/silverlight-4-beta/#tools

Here are few highlighted features of Silverlight 4 Beta in nutshell :

  • Out of Browser Applications - Elevated Privileges Support,COM interop
  • HTML Hosting Support
  • WebCam/Mic Support (raw stream only)
  • Printing Support
  • Notification aka “Toast” API
  • RichTextBox,Arabic and Hebrew Text Support
  • MouseWheel Support on ScrollViewer, TextBox, ComboBox, Calendar, DatePicker
  • DataBinding Support for DependencyObjects,IDataErrorInfo Support,StringFormat, TargetNullValue & FallBackValue Properties on Binding,IEditableCollectionView and Grouping support on CollectionViewSource
  • Astoria 2.0 Support,MEF
  • Expose Runtime Version to 3rd Party DLLs
  • NGEN Support for Core Runtime Binaries

iPhone Streaming now available : http://www.iis.net/iPhone

Silverlight Media Framework : http://smf.codeplex.com/

So out of this Treasure Box what we are going to discuss here? Well, I will touch upon highlighted features like Printing,WebCam/Mic Support, HTML Hosting,RichTextBox and our all time happening discussion here..DataGrid :)

So take a long breath and get ready for yet another drive with Silverlight..Silverlight 4 (Beta)..A long term player in world of RIA/Web..Way to go !! :)

Vikram.

Wednesday, November 11, 2009

Bing Maps Silverlight Control .. Wait for Map Control is over !

Hello everyone, hope you enjoying Silverlight and Expression Studio all the time. Well, For a long from Silverlight 2 onwards,we all are waiting for Map Control in Silverlight, Till the time we had DeepEarth Project and various other third party stuff, But now I am happy to share that we now have our own Map Control for our applications, Its free and very much simple to use. Just to give all control in your hand to allow you to explore, I am giving all information in very short manner..A quick review you can say.

Yes ! Bing Maps Silverlight Control is now available. So what you need?

1. Silverlight 3 Setup + Visual Studio and Expression Blend (Expression is optional) (Sorry to say..But with Silverlight 2 it might not work..document says so)

2. Bing Maps Silverlight Control : You can download it from here :

http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=beb29d27-6f0c-494f-b028-1e0e3187e830

3. You need to have account with : (Live ID is must)

https://www.bingmapsportal.com/

Once you install Bing Maps Silverlight Control, It will show you CHM file (If you really read that CHM carefully, you don’t need to read rest of my post,but please don’t do so :) ). All information is there in place with all necessary code snippets.

Now your job is to take normal Silverlight Application Project Template. Add Reference to your Silverlight Project to following dlls :

1. Microsoft.Maps.MapControl.Common.dll

2. Microsoft.Maps.MapControl.dll

You will find them usually under Program Files -> Bing Maps Silverlight Control -> V1-> Libraries

Then you need to set reference like this in your XAML file :

xmlns:BingMap="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl"

Then you need to write following XAML :

<BingMap:Map CredentialsProvider="Your Key Here"/>

Wait !..One step is mandetory before this, First you need to create Account with https://www.bingmapsportal.com/

You will get following UI once you perform login :

Capture

Well, you can see 3 options there :

1. Create an account : You need to enroll your self (Typical “I Agree all the terms” kind of stuff :D )

2. Create or View Keys : This is something similar to Silverlight Live Streaming account procedure, you need to give some name to your application and URL where you want this etc. For testing purpose you can give any URL (Specific URL is recommended though)

3. Update or View Account Details : Typical Account information.

Below these three you can find links to SDK and Blogs and forums which talk about Bing Map Control. (Ajax Control is also there beside Silverlight, My ASP.NET friends should give try for that too)

Then now come back to Visual Studio, Inside your app now, Place that key to “CredentialsProvider” and you done. Now you will see the Control on your designer like this :

Bing1

This even opens in Blend, If at all you want to place some design around it :

BlendBing

Control as such will not expose any properties which you can set-reset in Property windows, you need to play with XAML and C# Code.Now after all this just play with it by pressing F5 and you can see the output like this : (For this simple Hello World kind of example, there is no C# code, but once you start digging inside this control and Maps, you need to play with C#)

OutputBing

Not satisfied?? Want to have more stuff?..Want to handle its events? Want to place Videos,Images on it??..well you can do it easily by just few line of code !..No I am not taking that small pain..you can simply refer CHM along with it, For those CHM word does not make sense, it looks like this :

BingCHM

So, Now let it be your ASP.NET or HTML Page, Mapping with Bing Map Control will add value to your application and more important is that, Its Bing and its free..Bing Bing Bingo !! :)

Hope you like this post, I kept this small since this is very exciting and I don’t want to kill your excitement, Still if you feel I should drop some code snippets here, feel free to talk with me, Will then go for some more apps or another in depth post,Keep visiting here since very soon lot more new stuff is on your way !

Vikram.

Monday, November 9, 2009

Expression Encoder 3 Screen Capture : A small wonder…

Me and my other blogger friends all over the world already written many things about Expression Studio and Tools inside Expression Studio like Blend,Web,Encoder etc. With the launch of Expression Studio Version 3, Microsoft given us a simply amazing tool name as “Expression Encoder 3 Screen Capture” which though is not much talk about but already created wave in communities across the world.

While giving feedback to my articles here, Many suggested me that why I am not going for any screencasts here? Believe me, I still prefer typing long post over screencasts, But yes I am planning to have some screencasts in near future. When I took this activity and initiate it to hunt down a tool which will help me to do so, I found a big player in this arena as “Camtasia Studio”. My first impression was its freeware, then I realized that its paid software(They do give 30 days trial), well for good things cost hardly matters, But its always good to first look for other options. When I installed Expression Studio 3 on my machine, I was more keen towards Blend,Design and Encoder being a Silverlight enthusiast like you all, I totally neglected this Screen Capture that time (How dumb !).

Well, enough of story, now lets talk about Expression Encoder 3 Screen Capture. In a nutshell, Its a screen capturing utility introduce by Microsoft along with Expression Studio 3. You can find it in your start menu once you install Expression Studio 3. Once you click on that, you will find following on your screen :

Screen1

You can see four basic buttons on this UI, Out of these first two belong to Audio and Video, Then other two are Settings and Recording respectively. Once you click on Settings,you will find following window :

Screen2

You can see various Tabs here, each corresponds to some specific operation, Screen tab is only to set Bitrate and Frame rate, Camera Tab helps you to choose your Built-In Cam or attached cam for recording like this :

screen3

You will get all necessary settings option for your camera here. Moving ahead to Audio :

Screen4

It will help you to choose Audio Options and even here you can set Bitrate and Format in corresponding dropdowns, HotKey Tab basically help you to configure this player and you can set your own hotkeys here,else it will take default :

Screen5

Once all these setting are done, Another important Tab here is “Other” which will let you know where this screen capture going to get store and what other options are there like this :

Screen6

After these steps, Once you you back to main screen, After clicking on “Record” button, It will show you a Red Box covering your screen along with two free guidelines which will allow you to select which part of screen you want to capture, Remember by default it is screen as capturing object and not camera, For camera you need to go to Camera and do the necessary settings there. It will look like this :

Screen7

You have full freedom to set the size and/or some specific resolution by following option which you will get :

Screen8

After your recording, you will see a Preview of what you capture on screen like this :

Screen9

Screen10

At this Preview player, you have 2 options, First is to save this project as XESC format or Second option is to encode this properly via Encoder(Still you have to save that file before going to encoder), Yes you do have Encoder option at right side bottom of this preview player, Then story is pretty straight, Encode and upload it wherever you want, On blogs, forums anywhere, Silverlight hosting is definitely a good option always.

So, do you like this new way of doing Screen Captures? Isn’t it useful for Screencasts, This is power by Expression Encoder,Big plus point about this tool is the “simplicity” which we always find in any Microsoft Product.(Attempt here is not to blindly compare with Camtasia Studio or other screen capturing tools, But to create awareness about it since its part of Expression family).Its quick,efficient and most important is small in size..hence I name this tool as “A small wonder…”, I hope you like this article, This is bit away from Silverlight and Expression Blend and Design which we talk here a lot, But I found this tool worth blogging and I feel it might be useful to most of you, So I made this attempt. I am now again will go back to our main arena of Silverlight from next article. Thanks and let me know your feedback as usual.

Vikram.

Sunday, November 1, 2009

Expression Blend 3 SketchFlow : New era in Prototyping – Part 3

First of all sorry for delay in posting this last part of this series which is quick wrap up of first two, I was under heavy work load and rest of the time went into Windows 7 Party preparation which will be around next weekend.

In last part, we saw various aspects of SketchFlow and how we can improve our design with the SketchFlow controls, How we can program it and make it more real, We also saw how we can render that inside browser and navigate among various pages, Lastly we saw how we can give feedback with Ink tool provided to us and how it empower us to give correct feedback, We even went ahead and store feedback of that last example in a separate feedback file.

Now lets open that feedback file by going to Project->Add Existing Item.. Once you load that file you will see a Lamp kind of symbol inside Sketch Map and once you get your mouse pointer there, you will see the feedback available,Also you will see the corresponding feedback in your designer too like this :

feedback

loginfeedback

So, once we import this particular feedback file, Designer will be able to see the changes and what all things he/she need to improve in the same. This is how its very interactive for Designers,Developers as well as to Clients/End Users who give feedback.

What add cherry on the cake kind of thing is the feature introduced by Microsoft to import your Adobe Photoshop and Illustrator work inside blend and on top of that, You can scan images and make your design(Do refer videos shown on Virtual Kitchen), You can also import your PowerPoint work inside blend, So for these all you need is to visit File menu and you will get following options :

imports

Note that, for PowerPoint, there is no assurance that Animations inside PPT will work on Silverlight, This is a twist and there was lot many discussions went into community to have PPT with Animations directly exporting to Silverlight. Well, A paid solution is there, Check this out :

http://www.erain.com/products/convexion/default.asp?erain=cnvannc

Another question may come to your mind that, till this part of this article, I am talking all the scenarios happening on local machine, But how will one export that? A simple way to export this SketchFlow is just go to file Menu and choose “Package SketchFlow Project…” you will get following output :

export

Yes ! everything will be exported as a proper package and a TestPage is in place to check out.

Now for my designer friends, there is always a lot of pain to prepare documents and put these screens inside as specs, No wonder lot of efforts take place and time also get waste in that most of the time. But thanks to Microsoft who coming with new revolution in Blend and yes ! now you can create documentation of your design work. All you need is just save your work and go to File Menu-> “Export to Microsoft Word…” and see the magic ! :

doc1

doc2

doc3

Point to make a note here is that, if you open feedback file and export this to Word, you will not find the feedback reflected, So its a general export of your actual screen with a neat layout and schema in form of Microsoft Word Document (PDF?? well you need to take pain for that to export from doc/docx to PDF :) )

Well this was all about SketchFlow inputs I want to share with you and I am very sure this will help you a lot to move ahead in your prototype development, maybe in coming future I will try to build and demonstrate an end-to-end application via SketchFlow.

Meanwhile there is a must have book for SketchFlow which is a great refer which you can find it here :

http://www.dynamic-prototyping.com/

Another good resource you can find on my blogroll, Blog by Renuka Prasad, A fellow MVP in India and good friend of mine who have made some posts on Expression Blend SketchFlow, Check those too.

Thanks for your feedback and mails, I will soon back here with Silverlight and much more things.

Vikram.

Monday, October 19, 2009

Expression Blend 3 SketchFlow : New era in Prototyping – Part 2

Thanks for your wonderful response and emails for my Part 1 on Blend 3 SketchFlow. In last part basically I tried my best to put need of SketchFlow in front of you and things around that along with the initial steps to begin your SketchFlow work like how to add controls and what all options are there.

Today in this part, I am going to concentrate on Developing(coding) part along with navigation and much more till how to execute it etc. Maybe the exporting and other important features I will address in my part 3 (I don’t want my readers to feel sleepy with long long paragraphs :) ).

I assume here that, there are total 3 screens in my example application as Login->Welcome->Report, As arrow shows here the flow, without login you cannot move ahead. So flow starts from login screen and ends at Report.

For designers, good thing is that,they can give now smooth transition effects and small animations too while doing some functionality or screen change with something know as SketchFlow Animation like this :

sketchflowanimation

More in-depth information you can find here. As we talking from Part 1, Sketch Flow is all about making prototype more real and interactive. So we can even take help of code behind to make it as if a working code snippet. Let’s say on this Login Screen,If I want to validate user, I can write code for this prototype and make it realistic like this :

logincode

I can even associate navigation by means of trigger too by attaching-detaching it,something like this :

<i:Interaction.Triggers>
   <i:EventTrigger x:Name="MyTrigs" EventName="Click">
        <pb:NavigateToScreenAction TargetScreen="SilverlightPrototype1Screens.Screen_1_1"/>
   </i:EventTrigger>
</i:Interaction.Triggers>

There is yet another way to connect to another screen, Let’s say you have normal navigation button where you directly want to throw user on some specific screen then you can choose “Navigate To” option by just Right Clicking on it like this :

navigatescreen

Or directly associate particular screen via Map like this :

navimap

Note that One screen may connected to multiple screens and direction is not always one way, All depends on your vision of workflow among screens, So looping is common thing here.

Please make another note that, the Sketch Flow screens can be databound or you can have dummy data for them, How to DataBind screens in Blend, for this I have already written one article which you can refer here.

Now lets build this sample two screens and let’s now talk more on Output and execution part. So after building and executing project, you can see output in browser like this :

Output

Now let’s talk more specifically to each aspects and parts which we can see in above output, Check panel on Left first. (Well if you try to view source,you will find nothing but routine object tag embedding this output, So nothing specific or special there in terms of rendering), now lets concentrate on left panel :

Menu

Now Part 1 which is highlighted in Red is nothing but shows us the navigation sequence of screens, you can jump on your own to each of them either by clicking in that list or using Home and back button given on top of it. You will also notice that, your SketchFlow animation is also getting on list here along with screens. Part 2 which is again highlighted in Red is nothing but a scale where you can zoom in and out for particular screen on right hand side. Now let’s talk about Options Map and Feedback on down panel of this, It look like this :

map1

Highlighted icon may confuse you and you might think that it is for full screen, Actually this will overlap on your screen on right and there you can see the current selected screen and its position on map, which you can zoom in-out and can close too like this :

map2

If you ask me..from my own experience in IT, Hardly there will be any client who will not give any feedback and give go ahead on the spot, So feedback has to be there to improve work and do it more better and better. For this, You have a Feedback tab on left which look like this :

pens

With those pens and colors, you can draw or quote your remarks or feedback on screen on right like this :

Suggestions

Now not all the times these remark will help Designers to understand what exactly they are suppose to do, so we have a Text entry feature again made available which gives more information on what wrong on right side like this :

feedbacktxt 

Now a question may come to your mind that, what if I/My Client close down the browser? Where will that feedback get stored? am I going into loss for not having that data? Well, Simple answer is you have something known as “Feedback File” where all this information get stored, So all you need is just to click on Folder like symbol on left panel bottom part at right most button and then choose option like this :

feedoptons

Click on Export Feedback…

feedsave

and you are done ! You can then access that file from your drive or even you can transfer it wherever you want !

feedop

But what to do this Feedback file? and how will designer come to know feedback who might be sitting altogether at different location? Any other features where I can export my Output as Prototype? Well for all these questions, just wait for Part 3 where I will be talking about getting feedback file and how to extract feedback and make those changes along with much more powerful features..So be here once again for Part 3 with much more new things, I will take another day(Maybe on Tuesday) for Part 3 since as per my time zone,after few hours, it will be Monday Morning Blue for me !! :D

Like Part 1, I hope Part 2 will be helpful to take your development one step ahead, Do let me know your feedback.

Vikram.

Saturday, October 17, 2009

Expression Blend 3 Sketch Flow : New era in Prototyping … – Part 1

First of all, wishing my all blog readers a very Happy Diwali and wonderful year ahead ! Now its almost a month since I am writing something here, I was totally occupied with Community sessions for last two months, now got some time finally to be here with you all again !

Expression Blend 3 is nothing new for us, I have already talking about it since it was in Preview stage at the time of MIX09 around months of March, you can find more here :

http://pendsevikram.blogspot.com/2009/03/silverlight-3-explore-power-of-blend-3.html

Indian Software giant Infosys also made note of this article and they refer on their blog too : (Thanks Infosys !)

http://www.infosysblogs.com/microsoft/2009/03/blend_3_and_sl_3_preview_avail.html

Today, I am going to talk more on Blend 3 Sketch Flow feature which I never touch in past over here. Offcourse there are several resources on net available on Sketch Flow, but as usual here I will make it simple and straight for you without any confusing technical terms and also I will share right resources on net to refer.

To start Expression Blend 3 Sketch Flow, It is very important to first understand “Why you need Sketch Flow?”, This question may be already there in your mind,let me give you pictorial view of Design-Developer Application Cycle to make my point in front of you :

pic1

pic2

pic3

(Picture taken from http://lore.ua.ac.be/Teaching/SE3BAC/SoftwareSpecCartoon.gif   for just example purpose, it carries its respective copyright to its owner)

Well ! Above picture tell us that there is something went wrong in cycle. In above case, we will focus more on Designer and Developer part. Most of the time we have Best Industry designers with us and Best Industry Application Developers with us, but if there is no flow or smooth communication among them and their work, above things are common observations.

Microsoft as usual took lead to bring down the gap among Designer and Developers and they came up with Expression Blend, We all know now, how Blend and Visual Studio are tightly integrated, You do something there in Blend, you can see changes in Visual Studio and vice-versa.

For Designers, there is always challenge to build interactive prototypes for customers so as to give feel of application to customer in reality, Typically before tools like Blend Sketch Flow, we use to either build POCs (Again we need to put Man efforts in this activity) or we use to build designs in Excel or word, Drawback of this was, it does not helps to exactly put forth our point in front of client since they might not be that interactive and realistic which can give feel of application which we plan to build. Outcome of this is something like the picture above I have shown, You design something, Due to lack of awareness or right tools, something different gets designed and output is totally different than required !

Let me introduce Expression Blend 3 Sketch Flow which will give solution to all above concerns we raised above. All you need is to grab bits of Expression Blend 3 with Sketch Flow which you can find on Expression portal (Do you need url ?)

Once you install, it will show you following templates :

newsketchflow

Now you need to choose “Silverlight 3 SketchFlow Application” template along with your language choice. Then you can see following things :

1. SketchFlow Map :

sketchmap

2. SketchFlow Animation :

sketchanimation

3. Main Designer Window :

loginxaml

So, these are the three main blocks we need to look into more seriously as far as our prototyping is concern. By default you will get one screen and to add rest of it, you can do it via traditional way of adding new xaml pages or you can now take help of Sketch Flow map here like this :

skmap

You can see highlighted menu there above, each icon have its own meaning, let’s see one by one :

new This is for to “Create a Connected Screen”, A New Screen which you can then further connect with the existing screen.

new1 This is for “Connect to existing Screen”, All you need is to just drag-drop the arrow to the target screen to associate. It will represent connection by means of unidirectional blue color arrow.

newcomp This is for “Create and Insert a Component Screen”, Another good feature where you can add particular component which you feel is potential in your design workflow.

visualtag This is “Change Visual Tag” and very useful to highlight particular screen with some colors, This is given so as to set the priority screens or to highlight important screens or screen with important or same functionality etc. There is no generic guideline for this, however its purely matter of choice of designer !, Available colors are :

colorchoice

Now we are all set to design our prototype screens, So now its time to hunt for Controls, A normal way is we go to either toolbox or do it via XAML or take help of Asset Manager. Let me share this with you, for Sketch Flow, you have a set of unique Sketch Flow Controls which are similar to your traditional Silverlight Controls, Only difference is that they are especially made different as far as appearance is concerned and they look like someone drawn them with Pencil, Pencil shade looks to each control. Since we are building prototype (Which may turn into final design once client approved), it is good to go for Sketch Flow controls.

Point to be noted here is, Sketch Flow controls can have styles and effects like your other controls and last but not least, you can even write the corresponding C#/VB.NET code with them. So now go to Assets Tab and check for Sketch Controls like this :

assets

Note that each control is having extension as “-Sketch”, This is how you can differentiate among normal controls and sketch controls. Now all you need is just drag drop them on your designer and you are good to go !, Well you need to have Microsoft.Expression.Prototyping.SketchControls.dll on your system which you will get once you install Blend 3 Sketch Flow. If you are not able to see the controls for Sketch Flow, you can refer this thread which I started when I was stuck in early preview stages of Blend 3 Sketch Flow(http://social.expression.microsoft.com/Forums/en-US/blend/thread/5babede8-9cf6-4e1f-b968-1576cebb3e88), If that don’t help you, you can post your query on Expression forums and you will get support there by lot of expertise from Microsoft and from other experts.

Well now once you drag-drop controls on designers, then you may have questions like what to do next? Simple answer is just wait for one more day for my Part 2 article where I will cover how navigation works,what all things you can do,how to run this etc and in Part 2 or maybe even in Part 3, I will talk about exporting features, Documentation Features and much more ..so be here everyday to see more insightful visit of Blend 3 Sketch Flow.

I hope you like this Part 1 and it will help you to start your prototype work, Offcourse your designs will be way good than me since I am developer Silverlight MVP and have very average design sense :) ..but still I am sure in coming parts of this article, I will give you some very good inputs which will help you for months to come ahead.(The way Microsoft coming with its versions, I guess “Months” is a perfect word !!)

Do let me know your feedback and be ready for more in Part 2 and ahead..

Vikram.

Tuesday, September 15, 2009

Silverlight 3 DataGrid : Beyond Databinding …

First of all, Thank You all for your wonderful response for my last series on Silverlight 3 RIA Services for your LOB applications. When Silverlight 3 RTW was in place, before that time when it was in Beta, I wrote a series of articles on various capabilities in Silverlight 3 which includes DataForm,DataGrid and much more like pulling and pushing real data via WCF services to Database and vice-versa in very effective way.I am happy to tell that those articles still getting massive hits which I came to know recently from analytics. Thanks once again for your feedback.

Well, Today I am going to discuss few things which you generally “may” not have found in books or other places but which are equally important in terms of day to day business apps. Recently while doing few POCs, I got lot of feedbacks and common questions from customers about DataGrid which I am trying my best to address those in this article. I am though not much going to talk on PageCollectionView, Sorting and Grouping, I might cover those things in upcoming articles.

1. How Do I change Color of DataGrid Header ?

Well, for Background color you need to very much depend upon VSM (Visual State Manager) since directly Background property to header is not available. However with Style you can set/override foreground color of Header Text like this : (I am giving quick solution where I am talking about applying styles in limited scope and not globally)

xmlns:primitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data"

First you need to incorporate above namespace. The you can declare resource like this :

<UserControl.Resources>                         
    <Style TargetType="primitives:DataGridColumnHeader" x:Name="Vikram">
            <Setter Property="Foreground" Value="Red"/>                
    </Style>
</UserControl.Resources>

Then next step is to apply this Style to actual column like this:

<data:DataGridTextColumn Binding="{Binding FirstName}" HeaderStyle="{StaticResource Vikram}" Header="FirstName" />

And output will look like this :

HeaderStyle

2. Adding “Hand” Cursor to Header via Styles and without any code :

Some of you dropped me mail asking this requirement, Well this is certainly interesting and out of the box, Since Hand cursor should get displayed on Header part only and not on Rows, If you write like :

private void dg_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            this.Cursor = Cursors.Hand;
        }

This line of code is not going to help us to get the desired result and hence this time also we are going to take help of Styles directly. Point to be note here is that, if you try to set Cursor property from XAML, your attempts will fail since it does not expose such property. So write style like this below :

<UserControl.Resources>                         
<Style TargetType="primitives:DataGridColumnHeader" x:Name="Vikram">
<Setter Property="Cursor" Value="Hand"/>                               
</Style>
</UserControl.Resources>

Then again apply that style to Column Header as shown above.Note that, once you apply this Cursor, It might take some time/small delay to actually show Hand Cursor only on column header. This will help to display cursor Hand only on Column and not on rest of grid or rows.

3. No Data Display :

Most of the Third-Party Grids like Telerik etc, do provide features like No Data Display Template( I saw such thing for ASP.NET Grids from Telerik), Well it make sense to have such templates especially when you have your ItemSource or e.Result (Output from Service) as null.By default no such template is though available, what I am doing here is explicitly building a class with single property like this :

public class nodata
{
        public string Display { get; set; }        
}

Take little more effort to build a method where we can set message like this :

public List<nodata> NoDataDisplay()

    List<nodata> ndt = new List<nodata>();
    ndt.Add(new nodata() { Display = "No Data to Display.." });            
    return ndt;
}

Then final logic goes like this :

if (dg.ItemsSource == null)
{
    dg.Columns.Clear();
    dg.ItemsSource = NoDataDisplay();

   DataGridTextColumn textColumn = new DataGridTextColumn();
   textColumn.Header = "FirstName|LastName|Age|Email|SIG|WebCastDate|WebCastTime";
   textColumn.Binding = new Binding("Display");
   dg.Columns.Add(textColumn);

   dg.Height -= 245;
   dg.Width -= 250;

}
else
{
   dg.ItemsSource = GetSIGHeads();
}

Output will look like this :

NormalGrid

And if there is no data then :

NoDataDisplay

When I was scratching the Internet to get solutions on this, I hardly come across any for such requirement. So I went ahead and build my own logic. So I request you all to evaluate it and let me know if there is any better way to do it. Offcourse I will make your suggestion public giving full credit to you :)

4.Columns do get resized but not fully..How to reduce width to make them almost invisible.

Well, for some of my clients following was the situation :

DragCol1

This is the normal layout of grid, now in next situation, if user drag particular column, see what happens :DragCol2

Observe this carefully, User dragging LastName from left to right, As the default behavior it get shrink,But you can see it does not get shrink fully, so it becomes annoying a lot and looks like a stuck up column. So simple work around is to set MinWidth=0 and story ends ! For sample below I have set MinWidth of FirstName to 0 so here is the output :

<data:DataGridTextColumn Binding="{Binding FirstName}" HeaderStyle="{StaticResource Vikram}" Header="FirstName" MinWidth="0" />

DragCol3

Now you can see that there is not stuck up and you can drag any field and almost till respective on right or left will be overlapped.

5. Add Hyperlink to Cell..A Hyperlink and not Hyperlink Button !

Interesting ! a hyperlink and not hyperlink button, so idea is to just click on it and navigate, Any code behind event is not expected. Our job is to make it simple and workable in minimum workarounds and efforts, Solution :

<data:DataGridTemplateColumn>
  <data:DataGridTemplateColumn.CellTemplate>
      <DataTemplate>
          <HyperlinkButton Content="Click Me" TargetName="_blank" NavigateUri="http://www.silverlight.net">
           </HyperlinkButton>
       </DataTemplate>
   </data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>

and output will be like this :

Hyperlink

So you can redirect to any desired URL which you want and also you can specify location either same window or in new window by setting TargetName attribute. This is helpful to show Popup kind of window and render ASPX in it. But if you want to pass certain parameters to it, better watch out HTML DOM and limitations to do so before you directly take this as solution.

6. A Jazzy looking button is possible to be put in Grid?

Yes !, all you need to do it is to make use of Expression Design and Design a Jazzy button like this :

Delete

and then just add following code, Offcourse you will get event too for that button to write your code.

<data:DataGridTemplateColumn HeaderStyle="{StaticResource ColHead}">
  <data:DataGridTemplateColumn.CellTemplate>
     <DataTemplate>
        <Button x:Name="btnSave" Click="btnSave_Click">
           <Button.Template>
              <ControlTemplate>
                 <Image Source="Delete.png" Height="30" Width="80"/>
              </ControlTemplate>
           </Button.Template>
        </Button>
     </DataTemplate>
  </data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>

In such cases, be careful about Height and Width since they matter a lot in overall look and feel of the Grid.

7. How will you add Row Details ?

It can be simply added by following XAML Code :

<data:DataGrid.RowDetailsTemplate>
   <DataTemplate>
      <StackPanel Orientation="Horizontal" Background="AliceBlue">
          <TextBlock Width="200" Text="{Binding Email}" />
      </StackPanel>
   </DataTemplate>
</data:DataGrid.RowDetailsTemplate>

Since we have taken TextBlock, Advantage is that we can Wrap big amount of text and also apply various styles to the same. It is generally used to display the Description or Metadata of the particular row, It will be look like this :

RowDetails

Some Unsolved Mysteries for me for Silverlight DataGrid :

1. How to Merge two or more columns where we bind it with some collection?

2. Why there is always / most of the time a blank column look like dummy column getting bind to gird either on left or right, for most of the cases its on right side like this :

Unsolved Mystry

No Intellisense in CellTemplate ?? a Bug or Known Bug??

intellisense

Well, People address this issue as No Intellisense, actually you do get intellisense here but it is like almost not getting anything, ask me why? Simple answers is that this intellisense carries nothing interms of Standard Controls which we are looking ahead to embed it in the same. So work around is to whatever control you want to have inside it, declare it explicitly outside grid and do a copy-paste,what else can be done? :)

Normal Validations of Data in TextBox :

Before saying good bye for today, I would like to also drop a code snippet which many of you have ask me over mail, It is how one can validate certain fields especially Data entered in TextBox. In my old DataGrid article and DataForm article I have address this issue, but what if the TextBox is not part of those control and is independent?

Solution goes like this : I assume one layout where user suppose to enter his Birthdate, Logic to validate the Date part is what I am going to discuss here, the date is real birthdate or not is not part of our discussion.

if (!Regex.IsMatch(txtdob.Text, @"^([1-9]|0[1-9]|1[012])[- /.]([1-9]|0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$"))
{
      // An Invalid Date format was entered
      registerStatus.Text = "Invalid Date.Follow mm/dd/yyyy";
      txtdob.Select(0, txtdob.Text.Length);
      txtdob.Focus();
}

Do I need to tell more about Regex? I am sure you will be able to do it with multiple types of expressions like for Email, SSN etc. I am using RegisterStatus as error label to set-reset error messages and catching focus on the same control after error and highlighting it with Select( ), This is how it is simple to validate normal textbox controls,which may be part of your Data Entry or Registration of Users kind of applications.

We a talk a lot about small things in DataGrid which we never explore here before and we spend ample of time to bind data by various way. I hope information above will be useful for you and as usual your feedback is most welcome ! I am soon dropping few most post here which will address day to day problems which developers normally face especially if they don’t have any knowledge on Silverlight. So keep checking this place for lots of new things coming with much more interesting topics.

Vikram.