A Quick Look at Silverlight 2's DataGrid Control

If you follow my blog, you have probably noticed my obsession with data grids.  I haven't actually checked my archives, but if I had to guess I would bet somewhere around 70% of all my posts in some way include ASP.NET's Repeater, GridView or ListView controls.  Lately I have been taking a look at Silverlight 2 so naturally I was curious when I saw Scott Morrision's post titled Using the Silverlight DataGrid

I eagerly read through his post and started working on creating a very basic demo app.  I thought a good way to introduce myself to the DataGrid would be to build a page that allows me to set the values of the DataGrid properties so I could watch how it effects how the DataGrid presentation (usually this is what a designer is for, but it wasn't working so well for me.  I am sure it's user error.).  Anyway, I found this little app useful so I figured I would post the demo and source.     

Also, just in case you haven't seen - the Silverlight DataGrid supports column resizing and freezing column/row headers!  If you play around with the demo page you can see how this looks. 

Live Demo | Download

image

That's it.  Enjoy!


TrackBack

TrackBack URL for this entry:
http://mattberseth.com/blog-mt/mt-tb.fcgi/111

Comments


Posted by: Stephen Patten on March 23, 2008 12:00 AM

http://codebetter.com/blogs/david.hayden/archive/2008/03/23/orlando-code-camp-rocked-wcsf-and-data-access-tips-and-techniques-presentations.aspx

Recognize anything on this page.. What better way to say you ROCK! than to use your stuff.

Stephen

Just wanted to tell how much i interest and learn from your examples, the most thing made you different, is the live examples :)
thanks.

Hi,

yes it looks good! I have just encountered small bug which might be just in my PC. When I click Opacity the screen changes to blank?

Also does this grid has the sorting ability?

Posted by: Ethan Nagel on March 24, 2008 12:00 AM

Thanks for the example, Matt! Have you figured out how to implement Sorting in the DataGrid? I cant seem to get access to the Click event for the header ala WPF... is there another approach for SL2?

@Stepehn -
Yep - I sure do. And it looks great.

@Amr -
Yea, I wish more bloggers would do this. Code snippets are great, but I like being able to watch it live.

@ajaxus -
I havent had a problem with the opacity on either of my PCs (XP with IE7 or Vista with IE7). Anyone else seeing this?

@ajaxus, Ethan -
I havent figured that out yet, but it is on my short list. I will write up a quick post once I get it figured out.

Posted by: Hugo on April 1, 2008 12:00 AM

Compliments, great example.
About the Opacity, Im using Vista, IE7, Silverlight 2.0.30226.2, clicking an Opacity setting doesnt change the opacity here.

Posted by: Dave C on April 1, 2008 12:00 AM

The opacity works great for me (Vista, IE8), and thanks for the live demo, Matt.

Posted by: Richie Scott on April 2, 2008 12:00 AM

Matt,

Have you found a way of sizing the width of the columns based on the page size? I have also noticed that I always get an extra column on the right hand side of the grid to fill the space have you found a way of handling this?

Thanks
Richie

Posted by: David Roh on April 5, 2008 12:00 AM

Thank you Matt,

Very nice!

David

Posted by: Sam Covington on April 6, 2008 12:00 AM

Correction, not for any object, but for any arbitrary set of properties.

Thanks

This is beautiful!
Thank you, Matt!

Posted by: battery on August 29, 2008 11:55 PM

Have you found a way of sizing the width of the columns based on the page size? I http://www.batteryfast.co.uk have also noticed that I always get an extra column on the right hand side of the grid to fill the space � have you found a way of handling this?

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Consulting Services

Yep - I also offer consulting services. And heck, I'll do just about anything. If you enjoy my blog just drop me an email describing the work you need done.

Recent Comments

  • battery wrote: Have you found a way of sizing the width of the columns based on the page size? I <a href="http://ww...
  • Kevin Ortman wrote: This is beautiful! Thank you, Matt! ...
  • Sam Covington wrote: Correction, not for any object, but for any arbitrary set of properties. Thanks ...
  • David Roh wrote: Thank you Matt, Very nice! David ...
  • Richie Scott wrote: Matt, Have you found a way of sizing the width of the columns based on the page size? I have also n...
  • Hugo wrote: Compliments, great example. About the Opacity, Im using Vista, IE7, Silverlight 2.0.30226.2, clickin...
  • Dave C wrote: The opacity works great for me (Vista, IE8), and thanks for the live demo, Matt. ...
  • Matt Berseth wrote: @Stepehn - Yep - I sure do. And it looks great. @Amr - Yea, I wish more bloggers would do this. ...